Skip to content

Instantly share code, notes, and snippets.

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