The enumeration (enumeration) interface, although not part of the data structure itself, is widely used in other data structure categories. The enumeration (the enumeration) interface defines a way to retrieve contiguous elements from a data structure.
For example, an enumeration defines a method called Nextelement, which is used to get the next element of a data structure that contains multiple elements.
The enumeration defines a hasmoreelements method that is used to determine if there are more elements.
ImportJava.util.Vector;Importjava.util.Enumeration; Public classenumerationtest{ Public Static voidMain (String args[]) {enumeration months; Vector Monthsnumber=NewVector (); Monthsnumber.add ("January"); Monthsnumber.add ("February"); Monthsnumber.add ("March"); Monthsnumber.add ("April"); Monthsnumber.add ("May"); Monthsnumber.add ("June"); Monthsnumber.add ("July"); Monthsnumber.add ("August"); Monthsnumber.add ("September"); Monthsnumber.add ("October"); Monthsnumber.add ("November"); Monthsnumber.add ("December"); Months=monthsnumber.elements (); while(Months.hasmoreelements ()) {System.out.println (months.nextelement ()); } }}
-----Enumeration of Java data structures