Defining and Using Enumerations in Java


Enums are useful for variables that represent a fixed set of constants (e.g., days of the week, directions).

Source Code

enum Level {
    LOW,
    MEDIUM,
    HIGH
}

Level myVar = Level.MEDIUM;
System.out.println(myVar);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments