निम्न कोड ConcurrentModificationExcrption
क्यों फेंकता है, जब मैं मास्टर सूची के बाद उप सूची साफ़ करता हूं, लेकिन यदि मैं उप सूची को साफ़ करता हूं और फिर मास्टर सूची को साफ़ करता हूं?समवर्ती मोडिफिकेशन एक्सेप्शन जब एक उप सूची
ArrayList<Integer> masterList = new ArrayList<Integer>();
List<Integer> subList;
// Add some values to the masterList
for (int i = 0; i < 10; i++) {
masterList.add(i * i);
}
// Extract a subList from the masterList
subList = masterList.subList(5, masterList.size() - 1);
// The below throws ConcurrentModificationException
masterList.clear();
subList.clear(); // Exception thrown in this line
// The below doesn't throw any exception
subList.clear();
masterList.clear(); // No exception thrown. Confused??
यह बहुत जानकारीपूर्ण है। धन्यवाद। –