Iterator Interface

  • Applicable for all the Collection classes unlike Enumeration, hence it is the universal cursor
  • We can perform remove and read operations using Iterator

Synatx :

public Iterator c.iterator()

Methods :

  • public boolean hasNext()
  • public Object next()
  • public void remove()

Example :

Limitation of Iterator :

  • Iterator can move is forward direction only
  • Iterator cannot add or replace data into list

These limitations can be overcome by ListIterator

Leave a Comment