+ 2
can some explain the concept of enumeration for me
3 Respuestas
+ 1
@Tiger, what you explained is enum type not enumuation
http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html
0
Enumeration is an interface.
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<E> v:
for (Enumeration<E> 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 hashtable, and the values in a hashtable.
https://docs.oracle.com/javase/7/docs/api/java/util/Enumeration.html
- 1
Enumerations are a set of objects that represent a related set of choices:
Ex:
enum Animals {CAT, TIGER, LION}
Animals tiger = Animals.TIGER;
The method values() returns an array of the ordered list of objects defined for the enum.
Ex:
for (Animals a: Animals.values ()){
System.out.println (a);
}