SubList not an independent object, but it just gives an idea of ββthe source list and internally refers to the same list. Consequently, his design is apparently such that if the main list is modified structurally (adding / removing elements), he cannot fulfill his contract.
As you can see here, in the source code of SubList , the checkForComodification method checks to see if the base list has been changed and, therefore, if modCount (the number of times the list has been structurally changed), the SubList value SubList not match the parent ArrayList , then it throws ConcurrentModificationException
So, clearing the parent ArrayList from which the SubList was created can lead to certain SubList operations to result in a ConcurrentModificationException
Wand maker
source share