Interface Enumeration
All Packages Class Hierarchy This Package Previous Next Index
Interface Enumeration
public interface netscape.util.Enumeration
{
/* Methods
*/
public abstract boolean hasMoreElements();
public abstract Object nextElement();
}
The Enumeration interface specifies an API enabling iteration through a set
of elements. The following code demonstrates how to print all the values of
a Hashtable using an Enumeration:
Enumeration enumeration;
Object key;
enumeration = table.keys();
while (enumeration.hasMoreElements()) {
key = enumeration.nextElement();
System.out.println("key = " + key + ", value = " + table.get(key);
}
- See Also:
- NoSuchElementException
Methods
hasMoreElements
public abstract boolean hasMoreElements()
- Returns true if there are additional elements to enumerate.
nextElement
public abstract Object nextElement()
- Returns the next element of the enumeration. This method throws a
NoSuchElementException if hasMoreElements() returns
false.
All Packages Class Hierarchy This Package Previous Next Index
Copyright © 1997 Netscape Communications Corporation. All rights reserved
Please send any comments or corrections to ifcfeedback@netscape.com
HTML generated on 21 Apr 1997