Skip to content

Instantly share code, notes, and snippets.

@Unalo
Created December 6, 2019 08:50
Show Gist options
  • Save Unalo/727dcbe5ef49884e647683ad1d36cc1c to your computer and use it in GitHub Desktop.
Save Unalo/727dcbe5ef49884e647683ad1d36cc1c to your computer and use it in GitHub Desktop.
package SwitchExamples;
public class TestExample {
public static void main(String[] args) {
int a[] = {1, 2, 3};
int day = 0;
for (int p : a) {
switch (p) {
case 1:
day -=1;
System.out.println("Monday");
break;
case 2:
day +=7;
System.out.println("Tuesday");
break;
default:
System.out.println("Ayikho");
case 3:
day +=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");
case 7:
System.out.println("Sunday");
break;
}
}
System.out.println("day inside the loop " + day);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment