enum Week {
Monday, Tuesday, Wednesday, Thursday, Friday, Saturaday, Sunday
}
public class MainClass {
public static void main(String args[]) {
// Obtain all ordinal values using ordinal().
System.out.println("Here are all week constants" + " and their ordinal values: ");
for (Week day : Week.values())
System.out.println(day + " " + day.ordinal());
}
}
Here are all week constants and their ordinal values:
Monday 0
Tuesday 1
Wednesday 2
Thursday 3
Friday 4
Saturaday 5
Sunday 6