When I use an Iterator of Object I use a while loop (as written in every book learning Java, as Thinking in Java of Bruce Eckel):
I
There isn't much difference between those two methods, other than the first one remembers the value of it
after the loop. The second approach probably throws an error, because you redeclare the variable inside the loop.
There's actually a third method to this, aswell. Instead of writing e.g.
for (Iterator it = foo.iterator(); it.hasNext();) {
SomeObject so = foo.next();
}
you can most often write
for (SomeObject so: foo) {...}
These two equal to the same thing...