Package java.util |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
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
public abstract boolean hasMoreElements()Return Value:
Returns true if this enumeration contains more elements; false otherwise.
public abstract Object nextElement()Return Value:
Returns the next element of this enumeration.
Throw:
If no more elements exist.