我有一個數組,現在我想創建該數組的副本,以便我可以保留我的數組的以前的值,如果我想;在Android中爲Array創建一個數組副本?
我想是這樣的
System.arraycopy(firstArray, 0, secondArray, 0, firstArray.length);
但它給了我一個空指針異常即
08-26 13:20:08.421: E/AndroidRuntime(23739): FATAL EXCEPTION: main
08-26 13:20:08.421: E/AndroidRuntime(23739): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.iweentravel/com.android.iweentravel.MainAcvtivity}: java.lang.NullPointerException: dst == null
08-26 13:20:08.421: E/AndroidRuntime(23739): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
08-26 13:20:08.421: E/AndroidRuntime(23739): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
08-26 13:20:08.421: E/AndroidRuntime(23739): at android.app.ActivityThread.access$600(ActivityThread.java:149)
08-26 13:20:08.421: E/AndroidRuntime(23739): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
08-26 13:20:08.421: E/AndroidRuntime(23739): at android.os.Handler.dispatchMessage(Handler.java:99)
08-26 13:20:08.421: E/AndroidRuntime(23739): at android.os.Looper.loop(Looper.java:153)
08-26 13:20:08.421: E/AndroidRuntime(23739): at android.app.ActivityThread.main(ActivityThread.java:4987)
08-26 13:20:08.421: E/AndroidRuntime(23739): at java.lang.reflect.Method.invokeNative(Native Method)
08-26 13:20:08.421: E/AndroidRuntime(23739): at java.lang.reflect.Method.invoke(Method.java:511)
08-26 13:20:08.421: E/AndroidRuntime(23739): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
08-26 13:20:08.421: E/AndroidRuntime(23739): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
08-26 13:20:08.421: E/AndroidRuntime(23739): at dalvik.system.NativeStart.main(Native Method)
08-26 13:20:08.421: E/AndroidRuntime(23739): Caused by: java.lang.NullPointerException: dst == null
08-26 13:20:08.421: E/AndroidRuntime(23739): at java.lang.System.arraycopy(Native Method)
08-26 13:20:08.421: E/AndroidRuntime(23739): at com.android.iweentravel.MainAcvtivity.onCreate(MainAcvtivity.java:99)
08-26 13:20:08.421: E/AndroidRuntime(23739): at android.app.Activity.performCreate(Activity.java:5020)
08-26 13:20:08.421: E/AndroidRuntime(23739): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
08-26 13:20:08.421: E/AndroidRuntime(23739): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
08-26 13:20:08.421: E/AndroidRuntime(23739): ... 11 more
請建議我我如何能做到這一點,現在