Packages
Enumerations
Application
public class EnumApp { enum Grades {A, B, C, D, F}; // Line 1 enum Sports {BASEBALL, BASKETBALL, FOOTBALL, GOLF, HOCKEY, SOCCER, TENNIS}; // Line 2 public static void main(String[] args) // Line 3 { Grades myGrade; // Line 4 Sports mySport; // Line 5 myGrade = Grades.A; // Line 6 mySport = Sports.BASKETBALL; // Line 7 System.out.println("Line 8: My grade: " + myGrade); // Line 8 System.out.println("Line 9: The ordinal value of myGrade is " + myGrade.ordinal()); // Line 9 System.out.println("Line 10: myGrade name: " + myGrade.name()); // Line 10 System.out.println("Line 11: My sport: " + mySport); // Line 11 System.out.println("Line 12: The ordinal value of mySport is " + mySport.ordinal()); // Line 12 System.out.println("Line 13: My mySport name: " + mySport.name()); // Line 13 System.out.println("\nLine 14: Sports: \n"); // Line 14 for (Sports sp : Sports.values()) // Line 15 System.out.println(sp + "'s ordinal value is " + sp.ordinal()); // Line 16 System.out.println(); // Line 17 } }