What is a for-each loop?
Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.
What is a for-each loop?
Rating:
A for-each loop is an enhanced for loop. It used to iterate over arrays and collections. This feature was added to Java to make the access and retrieval of elements of arrays and collections faster. The syntax of a for-each loop is as follows:
{
}
where, itrvar is the variable that iterates through the elements of the collection.
Rating:
Was this information helpful?
Other articles
- What is the charAt() method?
- What is the if-else statement?
- What is a JAR file?
- String, StringBuffer and StringBuilder classes
- What is the decrement operator?