Menu

Showing posts with label Enum. Show all posts
Showing posts with label Enum. Show all posts

working with enum in Java

enum Level {
  LOW("A"),
  MEDIUM("B"),
  HIGH("C");
  
  	public final String value;
  
  	Level(String val){
  		value=val;
  	}
	public String getValue() {
        return value;
    }
}

public class Main { 
  public static void main(String[] args) { 
    String myVar = Level.HIGH.getValue(); 
    System.out.println(myVar); 
  } 
}

 


Output of enum value
Output