Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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