Run ❯
Get your
own Java
server
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Go to Spaces
Ctrl+Alt+P
enum Level { // Enum constants (each has its own description) LOW("Low level"), MEDIUM("Medium level"), HIGH("High level"); // Field (variable) to store the description text private String description; // Constructor (runs once for each constant above) private Level(String description) { this.description = description; } // Getter method to read the description public String getDescription() { return description; } } public class Main { public static void main(String[] args) { // Loop through all constants in the enum for (Level var : Level.values()) { System.out.println(var + ": " + var.getDescription()); } } }
LOW: Low level
MEDIUM: Medium level
HIGH: High level