Created
July 24, 2020 12:16
-
-
Save theboreddev/22cd85d067cd21f9a800ee63e1a4b5bc to your computer and use it in GitHub Desktop.
new_switch
This file contains hidden or 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
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