-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathIfElse.java
55 lines (46 loc) Β· 1.16 KB
/
IfElse.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package day1;
import java.util.Scanner;
public class IfElse {
/*
Time Complexity : O(1)
*/
public static void main(String[] args) {
/*
if (condition) {
code
} else if (condition2) {
code
} else if (condition3) {
code
}
.
..
..
..
else {
code
}
else is not compulsory
else if is not compulsory
*/
if (false) {
System.out.println("yeah!! i am in if");
}
// if (true) {
// System.out.println("i am in if block");
// } else {
// System.out.println("i am in else block");
// }
boolean itRains = false;
boolean weatherIsNice = false;
if (itRains) {
System.out.println("i will carry umbrella");
} else if (!itRains && weatherIsNice) {
System.out.println("i will go to picnic");
} else {
System.out.println("i will go cycling");
}
Scanner instrument = new Scanner(System.in);
// System.out.println("i am outside if else");
}
}