+ 2

can some explain the concept of enumeration for me

15th Aug 2016, 12:16 PM
Abdallah Ben Salif
Abdallah Ben Salif - avatar
3 Answers
+ 1
@Tiger, what you explained is enum type not enumuation http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html
15th Aug 2016, 2:30 PM
WPimpong
WPimpong - avatar
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
15th Aug 2016, 2:01 PM
WPimpong
WPimpong - avatar
- 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); }
15th Aug 2016, 2:09 PM
Tiger
Tiger - avatar