How-to articles, tricks, and solutions about SYNTACTIC-SUGAR

How does the Java 'for each' loop work?

The Java for-each loop, also known as the enhanced for loop, is a convenient way to iterate over the elements of an array or a collection. It eliminates the need to use an index variable to access the elements of the collection.