Null boolean values. Can someone simplify the explanation in the photo.
I understand that we can set Boolean values to false or true using mathematical calculations or string setting, but am confused as to when a Boolean would ever be "Null" or "NotNull".
In Java "bool" and "Boolean" are not quite equivalent.
"bool" is a primitive and only has 2 possible values - "true" or "false.
"Boolean" is an object and there can have 3 possible values - Boolean.TRUE, Boolean.FALSE or null.
e.g.
Boolean x = null ; // Legal
bool x = null ; // Won't compile
That being said, this warning is actually saying that they've looked at your code and figured out that "m1 is always 3".
So B5 = (m1 != 3) ; will always be false (since m1 is always 3). The null/non-null stuff isn't really coming into play in this instance - although it is good to understand them.
"bool" is a primitive and only has 2 possible values - "true" or "false.
"Boolean" is an object and there can have 3 possible values - Boolean.TRUE, Boolean.FALSE or null.
e.g.
Boolean x = null ; // Legal
bool x = null ; // Won't compile
That being said, this warning is actually saying that they've looked at your code and figured out that "m1 is always 3".
So B5 = (m1 != 3) ; will always be false (since m1 is always 3). The null/non-null stuff isn't really coming into play in this instance - although it is good to understand them.
Hope that helps,
Doug