Tuesday, November 29, 2011

What is the difference b/w Iterator & ListIterator

Iterator :--- Iterator takes the place of Enumeration in the Java collections framework. One can traverse throughr the the collection with the help of iterator in forward direction only and Iterators allow the caller to remove elements from the underlying collection during the iteration with well-defined semantics:Iterator is an interface which extract the data only forward direction.it is uni-directional interface.:Iterator and ListIterator are both are used for the displaying the (objects) elements.in Iterator interface the elements are displayed in the forward direction only by using the methods like hasNext(),next()this is only for forward direction and coming to ListIterator this is also used for displaying the elements in both forward and backward (by using hasPrevious(),previous()methods and as well as the Iterator mrthods also)direction .but the recommended is the Listiterator.
Category:Java Interview Questions

No comments:

Post a Comment