EnumExample1

EnumExample1 - + myGrade.name()); //Line 10...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
p public class EnumExample1 { 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: "
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: + 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: mySport name: " + mySport.name()); //Line 13 System.out.println("Line 14: Sports: "); //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 } }...
View Full Document

Ask a homework question - tutors are online