Enum inside a Class Example



This example demonstrates how to use Enum inside a Java class.
public class MyClass { 
  enum Level {
    LOW,
    MEDIUM,
    HIGH
  }

  public static void main(String[] args) { 
    Level myVar = Level.MEDIUM; 
    System.out.println(myVar); 
  } 
}
Output:
MEDIUM

Comments