-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSelectionSwitch.java
More file actions
32 lines (30 loc) · 817 Bytes
/
SelectionSwitch.java
File metadata and controls
32 lines (30 loc) · 817 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
public class SelectionSwitch {
public static void main(String[] args) {
int n = 2;
//If Statement
if(n == 1){
System.out.println("One");
}
else if(n == 2){
System.out.println("Two");
}
else{
System.out.println("Four");
}
// Switch Statement (supports Characters and Strings, don't supports doubles)
switch (n) {
case 1:
System.out.println("One");
break;
case 2:
System.out.println("Two");
break;
case 3:
System.out.println("Three");
break;
default:
System.out.println("No number matched");
break;
}
}
}