I\'ve run into this while writing a Traveling Salesman program. For an inner loop, I tried a
for(Point x:ArrayList) {
// modify the iterator
}
If you run the code and observe you find that first iteration of the loop works fine but the second throws ConcurrentModicationException
if is because next() method checks if the number of the elements did not change.
For nice explanation see http://javaadami.blogspot.com/2007/09/enhanced-for-loop-and.html