WHAT IS ADVANTAGES OF FOR-EACH LOOP

Jayden Bell

Total Post:13

Points:65
Posted by  Jayden Bell
 737  View(s)
Ratings:
Rate this:
  1. Jayden Bell

    Post:13

    Points:65
    What is advantages of for-each loop

    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.

      Modified On Jul-06-2016 03:53:57 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!