Enter your email address:

Delivered by FeedBurner


Thursday, March 29, 2012

Java Collection Framework - Iterator Interface

The iterator() method of the Collection interface returns and Iterator. An Iterator is similar to the Enumeration interface, Iterators differ from enumerations in two ways:
1.Iterators allow the caller to remove elements from the underlying collection during the iteration with well-defined semantics.
2. Method names have been improved.

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

The remove method is optionally suported by the underlying collection. When called and supported, the element returned by the last next() call is removed.

0 comments

Post a Comment