Skip to content

Instantly share code, notes, and snippets.

@BT-ICD
Created January 16, 2021 16:37
Show Gist options
  • Save BT-ICD/e7ed5852fb377da0d1e843cdf19cedeb to your computer and use it in GitHub Desktop.
Save BT-ICD/e7ed5852fb377da0d1e843cdf19cedeb to your computer and use it in GitHub Desktop.
Switch Case - To determine weekday name from a particular weekday number
/**
* 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