Does the following expression evaluate to true or false in Java?
null == false
I can't find any information about this on the internet.
Note that this question is about wrapped Boolean
value, and not about primitive boolean
/true
/false
.
Does the following expression evaluate to true or false in Java?
null == false
I can't find any information about this on the internet.
Note that this question is about wrapped Boolean
value, and not about primitive boolean
/true
/false
.
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.
The null
key word presents a pointer which point... nowhere. Which means Java can't get the value in the memory by it's index.
A boolean
is a memory value of 1 bit, 0 is false and 1 is true (or inverse). The value is get with the pointing index of the variable (if this boolean is stock in such a variable)
You can't check an equality between something representing nothing and a one bit value. Your line will throw an error !
Before ask, you should try this out yourself !
it gives The operator == is undefined for the argument type(s) null, boolean error
you can compare false == false or null == null;