SCJP Certification

Sun Certified Java Programmer Certification exam essentials

October 7th, 2009

What is the for-each loop?

Java Facts, by Daisy Williams.

A for-each loop is an enhanced for loop. It is 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:

for(type itrvar: collection)
{

}

where, itrvar is the variable that iterates through the elements of the collection.

Share

Back Top

Responses to “What is the for-each loop?”

Comments (0) Trackbacks (0) Leave a comment Trackback url
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

*