Output of the above program:

IteratorDemo.Java Output

Limitation of Iterator

It is unidirectional
cursor hence can only move forward.

ListIterator

ListIterator is given to
provide facilities like moving backward and forward in a list, adding an object, replacing
an object etc. This cursor can be operated on any List Object. It is a bi-directional cursor.

Methods of ListIterator Interface

public boolean hasNext()

These methods are provided to facilitate
the forward direction relation operation.

public Object next()

public int lastIndex()

public boolean hasPrevious()

These methods are provided to facilitate
the backward direction relation operation.

public Object previous()

public int previousIndex()

public void add(Object obj)

These methods are provided to facilitate
misc. Operations.

public void set(Object obj)

public void remove()

How to get ListIterator object ?

To get a ListIterator object we should use listIterator() method of List Interface.