In this example we will show you how to use an enum in a switch statement in Java.
Source Code
package com.beginner.examples;
enum Score {
A,
B,
C
}
public class SwitchEnum {
public static void main(String[] args) {
Score s = Score.A;
switch(s) { // switch the enum
case A:
System.out.println("A");
break;
case B:
System.out.println("B");
break;
case C:
System.out.println("C");
break;
}
}
}
Output:
A