Question: what is the difference between iterator and for loop?
Answer: Difference between the two traversals In for-each loop, we can't modify collection, it will throw a ConcurrentModificationException on the other hand with iterator we can modify collection. Modifying a collection simply means removing an element or changing content of an item stored in the collection.