An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Framework. Iterators differ from enumerations in two ways:

  Iterators allow the caller to remove elements from the
underlying collection during the iteration with well-defined
semantics.
Method names have been improved.

This interface is a member of the

Java Collections Framework.

Api Note

An Enumeration can be converted into an Iterator by using the Enumeration#asIterator method.

Param: the

type of elements returned by this iterator

Author

Josh Bloch

See

  • Collection
  • ListIterator
  • Iterable

Since

1.2

Type Parameters

  • E

Constructors

Methods

Constructors

Methods

  • Returns true if the iteration has more elements. (In other words, returns true if #next would return an element rather than throwing an exception.)

    Returns boolean

    true if the iteration has more elements