Przykłady wykorzystane w poście na temat nowych funkcji w Javie 13 dostępnego pod adresem:
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
int numLetters = switch (day) { | |
case MONDAY, FRIDAY, SUNDAY -> 6; | |
case TUESDAY -> 7; | |
case THURSDAY, SATURDAY -> 8; | |
case WEDNESDAY -> 9; | |
}; |
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
switch (day) { | |
case MONDAY, FRIDAY, SUNDAY -> System.out.println(6); | |
case TUESDAY -> System.out.println(7); | |
case THURSDAY, SATURDAY -> System.out.println(8); | |
case WEDNESDAY -> System.out.println(9); | |
} |
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
int numLetters; | |
switch (day) { | |
case MONDAY: | |
case FRIDAY: | |
case SUNDAY: | |
numLetters = 6; | |
break; | |
case TUESDAY: | |
numLetters = 7; | |
break; | |
case THURSDAY: | |
case SATURDAY: | |
numLetters = 8; | |
break; | |
case WEDNESDAY: | |
numLetters = 9; | |
break; | |
default: | |
throw new IllegalStateException("Wat: " + day); | |
} |
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
switch (day) { | |
case MONDAY: | |
case FRIDAY: | |
case SUNDAY: | |
System.out.println(6); | |
break; | |
case TUESDAY: | |
System.out.println(7); | |
break; | |
case THURSDAY: | |
case SATURDAY: | |
System.out.println(8); | |
break; | |
case WEDNESDAY: | |
System.out.println(9); | |
break; | |
} |
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
String html = """ | |
<html> | |
<body> | |
<p>Hello, world</p> | |
</body> | |
</html> | |
"""; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment