![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Iterators simplify for
loops. All you need in a for
loop's
Boolean expression is a hasNext
expression:
Iterator i = mainVector.iterator(); for (; i.hasNext();) { ... i.next() ... }
If you like, you can move variable declaration and initialization inside
the for
loop, producing a compact expression:
for (Iterator i = mainVector.iterator(); i.hasNext();) { ... i.next() ... }