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

  1. It is a very informative and useful post thanks it is good material to read this post increases my knowledge. Divorce Mediator

    ReplyDelete

Post a comment