allelopath
asked on
for iterator
I've just come across this code:
Is there a reason for using a for loop as opposed to a while loop?
Iterator myIterator = myArrayList.iterator();
for (; myIterator.hasNext(); ){
String string = (String) myIterator.next();
// do stuff
}
Is there a reason for using a for loop as opposed to a while loop?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>these days you can simplify
ah, that's why it was done. It is old code, probably written before enhanced for loops
ah, that's why it was done. It is old code, probably written before enhanced for loops
type "for loop vs while loop Java" in Google - tons of links and tons of opinions