1
JavaBeginner#strings#java15
A switch statement executes code blocks based on matching case labels and needs explicit break to avoid fall-through. A switch expression (with arrow syntax) returns a value directly, has no fall-through, and requires exhaustive coverage.
int day = 3;
String name = switch (day) {
case 1 -> "Mon";
case 2 -> "Tue";
default -> "Other";
};