Skip Top Navigation Bar

Java Patterns and Switch


Similar to Record Patterns, the Pattern Matching for Switch includes:

  • a type check in the form of case checks;
  • creation and assignment of variable; and
  • typecasting of the variable.

For example:

Your Turn

Let's use the Java Playground to test out these patterns.

Resources