~/ learn/ java-from-zero/ cards/ Switch expressions & pattern matching
1 of 2

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.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/e17f6566-5fd0-4dc0-a6b0-8b23459362fb/flashcard utf-8 LF