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 }
the first code is using an iterator so modifying the collection is not allowed. The second code you are accessing each object with x.get(i), so not using an iterator, modifications thus are allowed