Why is null == null false in Java?

4 Answers. You can’t compare null to a boolean . They are different types one indicating a null reference pointer and the other one a false/not true value. Thus the answer is: No this expression is not even valid and if it was, it would be false .

Sizin İçin Seçtik  How do you use equals method in Java for objects?

Leave a Reply

Your email address will not be published. Required fields are marked *

Why is null == null false in Java?

4 Answers. You can’t compare null to a boolean . They are different types one indicating a null reference pointer and the other one a false/not true value. Thus the answer is: No this expression is not even valid and if it was, it would be false .

Sizin İçin Seçtik  What is the difference between == and the equals () method?

Leave a Reply

Your email address will not be published. Required fields are marked *