Enum: ordinal()
/*
A 0
B 1
C 2
D 3
E 4
*/
enum Apple {
A, B, C, D, E
}
public class MainClass {
public static void main(String args[])
{
for(Apple a : Apple.values())
System.out.println(a + " " + a.ordinal());
}
}
Related examples in the same category