Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Beginning with Java 5.0 (Tiger), the Java language has a second kind of for loop called the enhanced for, that makes it easier to iterate over all the elements in an array or other kinds of collections (you’ll learn about other collections in the next chapter). That’s really all that the enhanced for gives you—a simpler way to walk through all the elements in the collection, but since it’s the most common use of a for loop, it was worth adding it to the language. We’ll revisit the enhanced for loop in the next chapter, when we talk about collections that aren’t arrays.
What it means in plain English: “For each element in nameArray, assign the element to the ‘name’ variable, and run the body of the loop.”
How the compiler sees it: