1 PackageCom.mon11.day4;2 /** 3 * Class Description: Defining enumerations4 * @authorAuthor: Chenyanlong5 * @versionCreation Date: November 4, 20176 */7 Public classTest {8 9 //Defining EnumerationsTen Public enumunit{ One U1,U2,U3 A } - - //Enumeration Methods the Public voidShow (unit unit) { - Switch(unit) { - CaseU1: -System.out.println ("The first chapter lays the groundwork")); + Break; - CaseU2: +System.out.println ("The second chapter lays the groundwork")); A Break; at CaseU3: -System.out.println ("The third chapter lays the groundwork"); - Break; - default: -SYSTEM.OUT.PRINTLN ("Incorrect input"); - } in } - to //Main Method + Public Static voidMain (string[] args) { -Test test=NewTest (); the test.show (UNIT.U1); * //test.show (UNIT.U2); $ //test.show (UNIT.U3);Panax Notoginseng } -}View CodeOperation Result:
Enumeration type---Java base code