Skip to content

Instantly share code, notes, and snippets.

@theboreddev
Created July 24, 2020 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theboreddev/22cd85d067cd21f9a800ee63e1a4b5bc to your computer and use it in GitHub Desktop.
Save theboreddev/22cd85d067cd21f9a800ee63e1a4b5bc to your computer and use it in GitHub Desktop.
new_switch
final DayOfTheWeek dayOfTheWeek = DayOfTheWeek.THURSDAY;
int position = switch (dayOfTheWeek) {
case MONDAY -> 1;
case TUESDAY -> 2;
case WEDNESDAY -> 3;
case THURSDAY -> 4;
case FRIDAY -> 5;
case SATURDAY -> 6;
case SUNDAY -> 7;
};
System.out.println("Day " + dayOfTheWeek + " is in position " + position + " of the week");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment