Why boolean in Java takes only true or false? Why not 1 or 0 also?
I was wondering today why Java cannot test any other type than a boolean.
In C, C++ and many other languages (actually most programming languages), the following is possible and valid:
int a = 0; if (a) // evaluates to false ; // do something nice a = 6; if (a) // evaluates to true ; // do something more
This also works almost everywhere for objects, arrays; anything that can have a value of
0x00000000 in the memory.
The question: why is this not possible in Java (you have to keep on testing for
== 0 or