Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created March 16, 2019 10:30
Show Gist options
  • Save ssaurel/24eb6af85df927e05a08673871087e2c to your computer and use it in GitHub Desktop.
Save ssaurel/24eb6af85df927e05a08673871087e2c to your computer and use it in GitHub Desktop.
Switch Java 12 on the SSaurel's Channel
public static boolean boolean isWeekend(String day) {
return switch (day) {
case "mon", "tue", "wed", "thu", "fri" -> false;
case "sat", "sun" -> true;
default -> {
if (day.startsWith("s")) {
System.out.println("It seems to be a weekend day");
break true;
}
System.out.printf("Unknown day: %s%n", day);
break false;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment