Created
December 16, 2021 20:36
-
-
Save agiri23/4662096021f52d5a6e73aaf8db7dfc3f to your computer and use it in GitHub Desktop.
pattern matching switch case with return value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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