I noticed this thing: my class has boolean
member and at some run-point I see it's value in debugger as null
. But when I use the getter method, it returns false
.
I know, most books tell you that boolean
in Java has only two values, unlike C/C++ in which every non-zero number can be interpreted as true
. So I wonder, what's happening in there?
Are there any other situations when some value of other type or null
can be interpreted as false
? Perhaps explanation of this is somewhere in JLS, could someone point me to it?
EDIT: Indeed yesterday was a bad day for debugging. First i wasted 4 hours to find a source of a bug which disapeared when i reversed source and made same changes again. Then this. I just tried to reproduce and couldn't. Was it galucination or it's just monday is a hard day? I don't know. Thanks everyone for your responses! I guess you can vote to close or delete this question now.
It sounds like the field is declared as the nullable, wrapper type Boolean
instead of a boolean
primitive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With