ConcurrentModificationException

This code will always throw ConcurrentModificationException:

for (Person person: group) {
group.remove(person);
}


Because:
You cannot remove an object from a collection while iterating through it.


To solve this problem, use the clear() method to remove all objects of a collection.

0 comments: (+add yours?)