We've learned to enumerate when we're learning programming languages, and now we're going to look at the use of enumerations in Java.
The code is as follows: public class Test { public static void main (string[] args) { Weekday w = Weekday.mon; System.ou T.println (w);//Will call ToString Method System.out.println (W.ordinal ());//print is the first few objects SYSTEM.OUT.PRINTLN of the enumeration list ( Weekday.values (). length)//Total number of enumerated objects  } public enum weekday{ Sat,mon,tue,wed,thu,fri,sat, Private Weekday () {  SYSTEM.OUT.PRINTLN ("one") } private weekday (int a) { system.out . println ("a"); }  } First defines a simple enumeration class weekday Sat,mon in this class. And so on is actually the object of the weekday class Note: Enumeration classes also have construction methods, the construction method must be private; It should be possible to understand the use of enumerated types through the following code, and to incorporate internal classes to understand code as follows: public enum trefficlamp{ Red (30) {//Red light Object invocation parameter is a construction method of int type, public trefficlamp Nextlamp () { R Eturn GREEN; &NBSP} }, GREEN { public trefficlamp Nextlamp () { return yellow; &NBSP} }, yellow (2) {  PUBLIC Trefficlamp Nextlamp () { return RED; } }; Public abstract Trefficlamp nextlamp (); private int time; Private Trefficlamp (int time) { this.time = time; }; }