How does an Iterator in Java know when to throw ConcurrentModification Exception
问题 I have the following code which throws ConcurrentModificationException because I am using two different iterators on the same list and one of them is modifying the list. So, the second iterator throws the exception when reading the list because some other iterator has modified the list. List<Integer> list = new ArrayList<>(); populate(list);//A method that adds integers to list ListIterator<Integer> iterator1 = list.listIterator(); ListIterator<Integer> iterator2 = list.listIterator(); while