Java Enumeration Interface and Vector Example

Enumeration interface is part of java.util package. An object that implements this interface generates a series of elements, one at a time. Successive calls to the nextElement() method return successive elements of the series.

Enumeration Interface Java SE

The above methods of this interface are used to enumerate through the elements of a vector, the keys of the hashtable and the values of the hashtable.

Note: The functionality of this interface is duplicated by the Iterator interface. In addition, Iterator adds an optional remove operation, and has shorter method names. New implementations should consider using Iterator in preference to Enumeration.

Let’s see Enumeration example using Vector.

Enumeration Example

Output

Related Posts

  • Iterator Interface and Example

Reference

Leave a Reply

avatar
  Subscribe  
Notify of