-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay_6_equal_to_and_ternary.java
More file actions
37 lines (26 loc) · 1.01 KB
/
Copy pathDay_6_equal_to_and_ternary.java
File metadata and controls
37 lines (26 loc) · 1.01 KB
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
package Programing.Section3;
public class Day_6_equal_to_and_ternary {
public static void main(String[] args) {
// assignment.java and equal to operator
boolean Entry = false;
if ( Entry = true ){
System.out.println(" this should not be printed 1.");
}
// THE MAJOR DIFFERENCE IS = SIGN IN BOTH OF THEM, ENTRY2 METHOD IS THE CORRECT WAY.
boolean Entry2 = false; // corrected method
if ( Entry2 == true){
System.out.println(" this should not be printed 2.");
}
// NOT operator
boolean iscar = false;
if (!iscar){
System.out.println("its a recommended way to check boolean is false");
}
// Ternary operator
boolean is_coding_easy = true;
boolean finethen = is_coding_easy ? true : false ;
if ( finethen ) {
System.out.println(" i will work hard to learn coding. ");
}
}
}