How does the Java ‘for each’ loop work?
Note that if you need to use i.remove(); in your loop, or access the actual iterator in some way, you cannot use the for ( : ) idiom, since the actual iterator is merely inferred. As was noted by Denis Bueno, this code works for any object that implements the Iterable interface. Note that if … Read more