An enum
is a special "class" that represents a group of constants (unchangeable variables, like final
variables).
enum Level { LOW, MEDIUM, HIGH }
You can access enum
constants with the dot syntax:
Level myVar = Level.MEDIUM;
Loop Through an Enum
The enum type has a values()
method, which returns an array of all enum constants.
for (Level myVar : Level.values()) { System.out.println(myVar); } // Outputs LOW MEDIUM HIGH
标签:MEDIUM,Java,Level,enum,myVar,Enums,constants From: https://www.cnblogs.com/ShengLiu/p/16928936.html