Here is an example of one:
class EnhancedForDemo {While writing this entry, I found a site which gives some direction on this, but still I am not totally tracking. Looking for a better description.
public static void main(String[] args){
int[] numbers = {1,2,3,4,5,6,7,8,9,10};
for (int item : numbers) {
System.out.println("Count is: " + item);
}
}
}
This format of the "for" loop is generally called the "enhanced for loop" and is used with arrays and collections.
Enhanced For
The Enhanced For Loop
Looks like this was only released with JDK 5.0. No wonder I couldn't find it in my outdated reference books...
2 comments:
http://java.sun.com/j2se/1.5.0/docs/guide/language/foreach.html
Post a Comment