- About us
The use of enhanced for loop enables us to loop through a collection member without knowing the size or explicitly iterating elements one by one . This feature is introduced with the Java SE platform in version 5.0.
Have a look how it simplifies programming.
Old form of looping.
for (int i=0; i < nameArray.length; i++)
System.out.println("Name: " + array[i]);
With Java SE 5.0. an enhanced looping would be like
for (String name : nameArray)
System.out.println("Name: " + name);
where nameArray is an array of Strings