You cannot modify a collection, for example by adding elements to it inside the loop, while you are iterating over that collection in a loop.
When you do that and the iterator finds out that you changed the collection without telling him, the iterator will get angry and it will throw a ConcurrentModificationException at you!
The only way to change the collection inside the look is by doing it through methods that are in the
iterator (not directly on the collection itself) so that the iterator knows about it.
If you call
it1.add(x); then a new element
is added to the collection.