/* Knowledge Points: Enumerations enumerations are a new type of data that is provided starting from Java5, a special class, which is the collection definition format for multiple constant objects: [modifier] enum enum class name { constant a, constant B, Constants c; }*///Define enumeration Enum weekday{ monday, tuesday, wednesday, thursday, friday, saturday, sunday; // The Monday in the enumeration type is equivalent to the original: Public static final weekday monday = new weekday ();} class employees{ private weekday restday; //which day of the week is rested (data type Weekday) public weekday getrestday () { return restday; } public void setrestday (weekday restday) //data type is weekday { this.restday = restday; }}public class enumerateexample{ Public static void main (String[] args) { employees e = new employees (); //Create an Employee object e.setrestday (weekday.wednesday); //set the break time by the class name, object, weekday restday = e.getrestday (); // Receive values with variable restday of type weekday if (restday == weekday.saturday | | restday == weekday.sunday) { system.out.println ("Weekend break ..."); } else { System.out.println ("Monday to Friday Rest ..."); } }}/* Weekday byte-code file contents (post-compilation with Java bytecode counter-compile tool): final class weekday extends enum // The custom Weekday enumeration class is inherited from the Java.lang in the underlying enum{ public static final weekday monday; public static final weekday tuesday; public static final weekday wednesday; public static final weekday thursday; public static final weekday Friday; public static final Weekday Saturday; public static final weekday sunday; private static final Weekday $VALUES []; public static weekday[] values () { return (weekday[]) $VALUES. Clone (); } public static weekday valueof (string s) { return (Weekday) enum.valueof (weekday, s); } private weekday (string s, int i) { super (s, i); } static { Monday = New weekday ("Monday", 0); tuesday = new weekday ("Tuesday", 1); wednesday = new weekday ("Wednesday", 2); thursday = new weekday ("Thursday", 3); friday = new weekday ("Friday", 4); saturday = new weekday ("Saturday", 5); sunday = new weekday ("Sunday", 6); $VALUES = (new weekday[] { Monday, Tuesday, Wednesday, Thursday, friday, saturday, sunday }); } }*/
Java Enumeration (ii): That is, the example in the Java enumeration (a) to expand