Traditional Switch
Console Output
Workbook 1c, p.121-123 — How Java routes execution through switch cases
int day =
| Feature | Traditional (break) | Enhanced (arrow) |
|---|---|---|
| Fall-through risk | Yes, need break | No, automatic |
| Syntax | case X: ... break; |
case X -> ... |
| Java version | All versions | Java 14+ |
| Recommendation | Works everywhere | Preferred when available |
switch checks one value against multiple cases
break or arrow syntax)
default is the catch-all, like else in if/else