Thursday, 2 August 2012

What is an Iterator interface in java?

    Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk through a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator.


      Method Summary
       boolean  hasNext() :
                                            Returns true if the iteration has more elements.
                         E   next() :
                                             Returns the next element in the iteration.
               void   remove() :
                                             Removes from the underlying collection the last element returned by the iterator (optional operation).
       

No comments:

Post a Comment