|
| |
| 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.
Explore the other Interface and Classes
of Java Collection Framework
Collection
Interface
Iterator
Interface
Set
Interface
List
Interface
ListIterator
Interface
Map
Interface
SortedSet
Interface
SortedMap
Interface
HashSet
& TreeSet Classes
ArrayList
& LinkedList Classes
HashMap
& Treemap Classes
Vector
and Stack Classes
|
|