Yunhee
0
Q:

Enum

// A simple enum example where enum is declared 
// outside any class (Note enum keyword instead of 
// class keyword) 
enum Color 
{ 
    RED, GREEN, BLUE; 
} 
  
public class Test 
{ 
    // Driver method 
    public static void main(String[] args) 
    { 
        Color c1 = Color.RED; 
        System.out.println(c1); 
    } 
}
4
enum Level {
  LOW,
  MEDIUM,
  HIGH
}
//You can access enum constants with the dot syntax:

Level myVar = Level.MEDIUM;
1

New to Communities?

Join the community