Packages  This Package  Prev  Next  Index  

§3.11 Interface Enumeration

public  interface  java.util.Enumeration
{
        // Methods
    public abstract boolean hasMoreElements();	§3.11.1
    public abstract Object nextElement();	§3.11.2
}
An object that implements the Enumeration interface generates a series of elements, one at a time. Successive calls to the nextElement method (I-§3.11.2) return successive elements of the series.

For example, to print all elements of a Vector v:

Methods are provided to enumerate through the elements of a vector (I-§3.10.13), the keys of a hash table (I-§3.4.11), and the values in a hash table (I-§3.4.8). Enumerations are also used to specify the input streams to a SequenceInputStream (I-§2.21)


Methods

hasMoreElements

public abstract boolean hasMoreElements()
Returns:
true if this enumeration contains more elements; false otherwise.

nextElement

public abstract Object nextElement()
Returns:
the next element of this enumeration.
Throws
NoSuchElementException (I-§3.14)
If no more elements exist.

Packages  This Package  Prev  Next  Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com