Name
Enumeration
Synopsis
Enumeration
is an interface that provides methods to access
an underlying sequence of objects that can be traversed in an
implementation-defined order. An Enumeration
is often used
to traverse the elements of a Vector
as an alternative to
directly accessing each element by its index.
The hasMoreElements()
method returns
false
if the Enumeration
is empty or
has already returned its last element. The first call to
nextElement()
returns the first element in the
Enumeration
, if it is not empty. Each subsequent
invocation of this method returns the following element. Calling this method
after the last element has been returned results in a
NoSuchElementException
. The
hasMoreElements()
is typically called before each use of
nextElement()
to check whether the end of the sequence has
been reached. Note that the values of an Enumeration
can be iterated through only once; there is no way to reset it to the
beginning.
public interface Enumeration { // Public Instance Methods public abstract boolean hasMoreElements(); public abstract Object nextElement(); }
Returned By
Hashtable.{elements(), keys()}
, Vector.elements()
Get J2ME in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.