Why the default case always run?
public class HelloWorld {
public enum ScenarioState {
INIT,
START,
STOP,
DESTROY
}
public static void displayRecord(ScenarioState state) {
switch (state) {
case INIT:
case START:
case STOP:
System.out.println("1");
default:
System.out.println("default");
}
}
public static void main(String[] args) {
ScenarioState state = ScenarioState.INIT;
displayRecord(state);
}
}
The expected output should be
1
but the actual Output:
1
default
Why cause this problem? anyone can help me