Package java.util Previous
Previous
Java API
Java API
Index
Index
Next
Next

Interface Enumeration

Methods

public  interface  java.util.Enumeration
{
        // Methods
    public abstract boolean hasMoreElements();	
    public abstract Object nextElement();	
}

An object that implements the Enumeration interface generates a series of elements, one at a time. Successive calls to the nextElement method return successive elements of the series.

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

for  (Enumeration  e  =  v.elements()  ;  e.hasMoreElements()  ;)  {	        System.out.println(e.nextElement());
} 

Methods are provided to enumerate through the elements of a vector , the keys of a hash table , and the values in a hash table . Enumerations are also used to specify the input streams to a SequenceInputStream


Methods


hasMoreElements

public abstract boolean hasMoreElements() 

Return Value:

Returns true if this enumeration contains more elements; false otherwise.


nextElement

public abstract Object nextElement() 

Return Value:

Returns the next element of this enumeration.

Throw:

NoSuchElementException

If no more elements exist.



Top© 1996 Sun Microsystems, Inc. All rights reserved.