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 switchSample1(DayOfWeek dayOfWeek) { | |
return switch (dayOfWeek) { | |
case MONDAY, TUESDAY: | |
yield 1; | |
case WEDNESDAY, THURSDAY, FRIDAY: | |
yield 2; | |
case SATURDAY: | |
yield 3; | |
case SUNDAY: | |
yield 4; | |
}; | |
} | |
int switchSample2(DayOfWeek dayOfWeek) { | |
return switch (dayOfWeek) { | |
case MONDAY, TUESDAY -> 1; | |
case WEDNESDAY, THURSDAY, FRIDAY -> 2; | |
case SATURDAY -> { | |
System.out.println("Hello"); | |
yield 3; | |
} | |
case SUNDAY -> 4; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment