Created
January 15, 2021 13:51
-
-
Save gyselph/9c0071ca89a5960bd2243d17c6165db7 to your computer and use it in GitHub Desktop.
Java 7 to 15: new switch
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
jshell> var i = 3; | |
jshell> var x = switch(i) { | |
...> case 1 -> "one"; | |
...> case 2 -> "two"; | |
...> case 3 -> "three"; | |
...> default -> "unknown number"; | |
...> }; | |
x ==> "three" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment