Created
December 6, 2019 08:50
-
-
Save Unalo/727dcbe5ef49884e647683ad1d36cc1c to your computer and use it in GitHub Desktop.
This file contains 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
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