The for-each statement was introduced with the release of Java 5. It is sometimes referred to as the enhanced for loop. Advantages of using the for-each statement include:
The for-each statement is used in conjunction with collections and arrays. It provides an easier way to iterate through each member of an array or class that has implemented the
java.util.Iterable interface. As the
Iterable interface is the super interface of the
java.util.Collection interface, the for-each statement can be used with those classes that implement ...