我是TreeMap的新用戶。TreeMap Force關閉
我曾嘗試下面的代碼:
for(Map.Entry<Integer,Integer> entry : MultiSelect_TreeMap.entrySet()) {
int Books = entry.getValue();
for(Map.Entry<Integer,Integer> entry2 : MultiSelect_TreeMap2.entrySet()) {
int CalculatedBooks = entry2.getKey();
int Books2 = entry2.getValue();
int Pages = CalculatedBooks - (BooksPos * MaxPos);
MySQLITE_DATABASE.DeleteIfExist(Books, Pages);
if(Books == Books2)
{
MultiSelect_LinkedList.add(Pages);
MultiSelect_TreeMap.remove(CalculatedBooks);
MultiSelect_TreeMap2.remove(CalculatedBooks);
}
}
}
但我正在部隊密切錯誤:
的logcat:
10-20 08:15:54.220: E/AndroidRuntime(764): FATAL EXCEPTION: main
10-20 08:15:54.220: E/AndroidRuntime(764): java.util.ConcurrentModificationException
10-20 08:15:54.220: E/AndroidRuntime(764): at java.util.TreeMap$MapIterator.stepForward(TreeMap.java:883)
10-20 08:15:54.220: E/AndroidRuntime(764): at java.util.TreeMap$EntrySet$1.next(TreeMap.java:924)
10-20 08:15:54.220: E/AndroidRuntime(764): at java.util.TreeMap$EntrySet$1.next(TreeMap.java:922)
10-20 08:15:54.220: E/AndroidRuntime(764): at test.project.MainActivity.DeleteAllSelectedNames(MainActivity.java:1012)
10-20 08:15:54.220: E/AndroidRuntime(764): at test.project.MainActivity$15.onClick(MainActivity.java:1274)
10-20 08:15:54.220: E/AndroidRuntime(764): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
10-20 08:15:54.220: E/AndroidRuntime(764): at android.os.Handler.dispatchMessage(Handler.java:99)
10-20 08:15:54.220: E/AndroidRuntime(764): at android.os.Looper.loop(Looper.java:137)
10-20 08:15:54.220: E/AndroidRuntime(764): at android.app.ActivityThread.main(ActivityThread.java:5103)
10-20 08:15:54.220: E/AndroidRuntime(764): at java.lang.reflect.Method.invokeNative(Native Method)
10-20 08:15:54.220: E/AndroidRuntime(764): at java.lang.reflect.Method.invoke(Method.java:525)
10-20 08:15:54.220: E/AndroidRuntime(764): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
10-20 08:15:54.220: E/AndroidRuntime(764): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-20 08:15:54.220: E/AndroidRuntime(764): at dalvik.system.NativeStart.main(Native Method)
能有人告訴我我做錯了什麼?
非常感謝
您可以在快速枚舉地圖時修改地圖的內容。你不能這樣做。 – njzk2 2014-10-20 13:36:57