Skip to content

Instantly share code, notes, and snippets.

@agiri23
Created December 16, 2021 08:55
Show Gist options
  • Save agiri23/881770456208b2e831eeb22386e43931 to your computer and use it in GitHub Desktop.
Save agiri23/881770456208b2e831eeb22386e43931 to your computer and use it in GitHub Desktop.
switch case with pattern matching
public static void onShow(Country country) {
switch (country) {
case NETHERLANDS, POLAND, GERMANY -> System.out.println("European Country");
case INDIA, BHUTAN, NEPAL -> System.out.println("Asian Country");
default -> System.out.println("It's from Wakanda");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment