Bidirectional traversing with ListIterator

Do you need a bidirectional way to skip through a list?

A rewind – forward behavior?

Traversing the list in one way and then in the opposite direction?

The Java ListIterator in the java.util package is here ready made to your help.

An iterator for lists that allows the programmer to traverse the list in either direction.

The previous() and hasPrevious() methods are available in this class and will make the trick.

You can build a ‘media tape’ behaviour on top of it.


It has some loose relationships with the Elevator Algorithm used for seeking a disk in its most simplest implementation strategy, the FCFS, First Come First Served. I used this one before for other purposes than seeking a disk.

Leave a Reply

Your email address will not be published. Required fields are marked *