Iterating an object collection in Java SE 6 is straight forward.
below is the example.
below is the example.
Traditional form:
Iterator it = collection.iterator();
while(it.hasNext()){
Object o = it.next();
System.out.println(o);
}
while(it.hasNext()){
Object o = it.next();
System.out.println(o);
}
SE 6:
for(Object o: collection)
System.out.println(o);
for(Object o: collection)
System.out.println(o);
No comments:
Post a Comment