ListIterator Interface

  • ListIterator is bidirectional cursor, it can move forward as well as backward
  • We can perform Read, Remove, Replace and Add operation using ListIterator
  • ListIterator is a child interface of Interator and Hence all methods present in Iterator is present in ListIterator
  • We can create list iterator by using listIterator() method of List Interface
  • It is the most powerful cursor but is applicable only for list objects
  • How to get ListIterator object
    public ListIterator listIterator()
    Example : ListIterator ltr = l.listIterator();
  • Methods 9 methods:
    • Forward Methods
      • public boolean hasNext()
      • public Object next()
      • public int nextIndex()
    • Previous Methods
      • public boolean hasPrevious()
      • public Object previous()
      • public int previousIndex()
    • Manipulation Methods
      • public void remove();
      • public void add(Object o)
      • public void set(Object o);

Leave a Comment