Link to home
Start Free TrialLog in
Avatar of polkadot
polkadot

asked on

Java Iterator next method?

In 1.4.2


Iterator itr = ...;

itr.next() gets the next object and advances the iterator?  How do I get it so that it only advances when I want it to.

For instance I need to retrieve the value referenced by the iterator several times during this block of code.

Avatar of hoomanv
hoomanv
Flag of Canada image

Some collection use ListIterator which enables previous() as well as next()
You can get the element with next() and then rewind it by previous()
ASKER CERTIFIED SOLUTION
Avatar of valipotor
valipotor

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial