Created
January 16, 2021 16:37
-
-
Save BT-ICD/e7ed5852fb377da0d1e843cdf19cedeb to your computer and use it in GitHub Desktop.
Switch Case - To determine weekday name from a particular weekday number
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
/** | |
* About switch case | |
* Program to get weekday name. Initialize value with weekday number | |
* 0 - Sunday | |
* */ | |
public class SwitchCaseDemoWeekDayName { | |
public static void main(String[] args) { | |
byte weekDayNum=0; | |
switch (weekDayNum){ | |
case 0: | |
System.out.println("Sunday"); | |
break; | |
case 1: | |
System.out.println("Monday"); | |
break; | |
case 2: | |
System.out.println("Tuesday"); | |
break; | |
case 3: | |
System.out.println("Wednesday"); | |
break; | |
case 4: | |
System.out.println("Thursday"); | |
break; | |
case 5: | |
System.out.println("Friday"); | |
break; | |
case 6: | |
System.out.println("Saturday"); | |
break; | |
default: | |
System.out.println("Invalid number, initialize value between 0-6"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment