-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11 Ternary and switch.txt
More file actions
62 lines (50 loc) · 950 Bytes
/
11 Ternary and switch.txt
File metadata and controls
62 lines (50 loc) · 950 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
public class SelectionDemo
{
// ternary operator
// ?: -> condition?expr1:expr2
public static void main(String args[])
{
// int i = 5;
// int j = 0;
// if(i>6)
// j=1;
// else
// j=2;
// j = i>6?1:2;
// System.out.println(j);
// Switch Statement
// int n = 6;
//
// switch(n)
// {
// case 1:
// System.out.println("One");
// break;
// case 2:
// System.out.println("Two");
// break;
// case 3:
// System.out.println("Three");
// break;
// case 4:
// System.out.println("Four");
// break;
// case 5:
// System.out.println("Five");
// break;
// default:
// System.out.println("No Match");
String d = "abc";
switch(d)
{
case "abc":
System.out.println("One");
break;
case "pqr":
System.out.println("Two");
break;
default:
System.out.println("No Match");
}
}
}