The values( ) method returns an array that contains a list of the enumeration constants.
Example of values() method
enum Apple {
Jonathan, GoldenDel, RedDel, Winesap, Cortland
}
class EnumDemo2 {
public static void main(String args[])
{
Apple ap;
System.out.println(“Here are all Apple constants:”);
// use values()
Apple allapples[] = Apple.values();
for(Apple a : allapples)
System.out.println(a);
System.out.println();
}
}
The output from the program
Here are all Apple constants:
Jonathan
GoldenDel
RedDel
Winesap
Cortland