Pages

Friday, July 11, 2008

For Loop (SE 6)

Iterating an object collection in Java SE 6 is straight forward.
below is the example.

Traditional form:
Iterator it = collection.iterator();
while(it.hasNext()){
Object o = it.next();
System.out.println(o);
}


SE 6:
for(Object o: collection)
System.out.println(o);

No comments:

Post a Comment