A classic switch statement runs every case from the matched label onward until a break, while a switch using arrow labels executes only the matched branch.
int day = 3;
StringBuilder oldStyle = new StringBuilder();
switch (day) {
case 1:
case 2:
case 3:
oldStyle.append("weekday-ish ");
case 4:
oldStyle.append("falls-through");
break;
default:
oldStyle.append("other");
}
String arrowResult = switch (day) {
case 1, 2, 3 -> "weekday-ish";
case 4 -> "thursday";
default -> "other";
};
System.out.println("Old style: " + oldStyle);
System.out.println("Arrow style: " + arrowResult);
Old style: weekday-ish falls-through
Arrow style: weekday-ish
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-09-27