-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitchcase.java
38 lines (31 loc) · 907 Bytes
/
switchcase.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.company;
public class switchcase {
public static void main(String[] args) {
int i = 8;
String s = "Hii";
switch (i)
{
case 1:
System.out.println("One");
break; // we use break to break the condition once it is executed
case 2:
System.out.println("Two");
break;
case 6:
System.out.println("Six");
break;
case 10:
System.out.println("Ten");
break;
default: // default case if no case satisfies the condition
System.out.println("Some number");
}
switch (s)
{
case "Hi":
System.out.println("Not matched");
case "Hii":
System.out.println("Matched");
}
}
}