-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNestedSwitchCase.java
More file actions
48 lines (36 loc) · 986 Bytes
/
NestedSwitchCase.java
File metadata and controls
48 lines (36 loc) · 986 Bytes
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
39
40
41
42
43
44
45
46
47
48
// Following is a simple program to demonstrate
// syntax of Nested Switch Statements.
import java.io.*;
class NestedSwitchCase {
public static void main (String[] args)
{
int x = 1, y = 2;
// Outer Switch
switch (x) {
// If x == 1
case 1:
// Nested Switch
switch (y) {
// If y == 2
case 2:
System.out.println("Choice is 2");
break;
// If y == 3
case 3:
System.out.println("Choice is 3");
break;
}
break;
// If x == 4
case 4:
System.out.println("Choice is 4");
break;
// If x == 5
case 5:
System.out.println("Choice is 5");
break;
default:
System.out.println("Choice is other than 1, 2 3, 4, or 5");
}
}
}