Skip to content

Commit 757ac5a

Browse files
committed
null does not evaluate to false
1 parent c7d897f commit 757ac5a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎src/Main.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,12 @@ public static void main(String[] args) {
1212
// Object.equals will check for null
1313
System.out.println("person equal null: " + Objects.equals(p1, null));
1414
System.out.println("both person equal: " + Objects.equals(p1, p2));
15+
16+
// this will error out. will have to compare will null as below
17+
// have mixed feelings about this.
18+
// if (null) System.out.println("null is true");
19+
20+
// this works
21+
if (null == null) System.out.println("null is true");
1522
}
1623
}

0 commit comments

Comments
 (0)