Every case block needs a break statement at the end. Without it, execution "falls through" into the next case, running code you didn't intend.
int x = 1;
switch (x) {
case 1:
System.out.println("One");
break;
case 2:
System.out.println("Two");
break;
default:
System.out.println("Other");
}
The break tells Java to exit the switch block immediately. After running the matching case's code, break jumps to the first line after the closing brace of the switch.
Without break on case , Java would print "One" and then continue into case and print "Two" as well. This is the single most common source of bugs in switch statements. Always add break unless you have a specific reason not to.