Fall-through happens when a case block has no break. Java does not stop at the end of a case. It keeps executing the next case's code until it hits a break or the switch ends.
Sometimes this is useful. You can group multiple cases that share the same logic:
int month = 3;
switch (month) {
case 12:
case 1:
case 2:
System.out.println("Winter");
break;
case 3:
case 4:
case 5:
System.out.println("Spring");
break;
default:
System.out.println("Other season");
}
Months , , and all print "Spring". Cases and have no code and no break, so they fall through to case 's code.
Intentional fall-through is fine when grouping. Accidental fall-through causes silent bugs. If you leave out a break on purpose, add a comment like // fall through so other developers know it's intentional.