Type an arrow switch expression
Type an arrow switch expression
Answer
String name = switch (day) { case 1 -> "Mon"; default -> "?"; };
The arrow form returns a value, needs no break, and cannot fall through. Note the semicolon after the closing brace — it is an expression.