Enums in Java


Enums are used to define a collection of constants, making your code more readable and maintainable.

Source Code

enum Level {
    LOW,
    MEDIUM,
    HIGH
}
public class Main {
    public static void main(String[] args) {
        Level myVar = Level.MEDIUM;
        System.out.println(myVar);
    }
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments