Advantages of for-each loop
· The for-each construct is very useful if we want to traverse all the elements of the array.
· Specifically, it allows us to iterate over collections and arrays without using iterators or index variables. Although the for statement is quite powerful, it is not optimized for collection iteration.
· The for-each construct can be easily used to dump all the elements of an array on the user console. However, the same thing can be easily achieved by using the toString() method of the Arrays class.