1switch(x){
2 case(0): //if x == 0
3 //do some stuff
4 break;
5 //add more cases
6 default: //when x does not match any case
7 //do some stuff
8 break;
9}
1// Java switch case with string
2public class SwitchCaseWithString
3{
4 public static void main(String[] args)
5 {
6 String str = "twelve";
7 switch(str)
8 {
9 case "ten":
10 System.out.println("ten");
11 break;
12 case "eleven":
13 System.out.println("eleven");
14 break;
15 case "twelve":
16 System.out.println("twelve");
17 break;
18 default:
19 System.out.println("doesn't match");
20 }
21 }
22}