CopyOnWriteArrayList<Options> Options= new CopyOnWriteArrayList<Options>();
Options Options = Options.get(selectedFilterIndex);
我在上面的行中收到错误。选项是一个 ArrayList。我尝试了ArrayList
as well CopyOnWriteArrayList
,但得到以下错误。如何处理此类异常。
06-21 15:28:23.257: E/XXX(8985): Uncaught exception is: 06-21 15:28:23.257: E/XXX(8985): java.lang.RuntimeException: An error occured while executing doInBackground() 06-21 15:28:23.257: E/XXX(8985): at android.os.AsyncTask$3.done(AsyncTask.java:278) 06-21 15:28:23.257: E/XXX(8985): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) 06-21 15:28:23.257: E/XXX(8985): at java.util.concurrent.FutureTask.setException(FutureTask.java:124) 06-21 15:28:23.257: E/XXX(8985): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307) 06-21 15:28:23.257: E/XXX(8985): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 06-21 15:28:23.257: E/XXX(8985): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 06-21 15:28:23.257: E/XXX(8985): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 06-21 15:28:23.257: E/XXX(8985): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 06-21 15:28:23.257: E/XXX(8985): at java.lang.Thread.run(Thread.java:856) 06-21 15:28:23.257: E/XXX(8985): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 06-21 15:28:23.257: E/XXX(8985): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251) 06-21 15:28:23.257: E/XXX(8985): at java.util.ArrayList.get(ArrayList.java:304) 06-21 15:28:23.257: E/XXX(8985): at com.usercontext.CommonActivity$6.doInBackground(AppointmentsActivity5.java:354) 06-21 15:28:23.257: E/XXX(8985): at com.usercontext.CommonActivity$6.doInBackground(AppointmentsActivity5.java:1) 06-21 15:28:23.257: E/XXX(8985): at android.os.AsyncTask$2.call(AsyncTask.java:264) 06-21 15:28:23.257: E/XXX(8985): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)