DRAFT
Observed
Numeric types can be coerced to boolean
Numeric types cannot be coerced to boolean
Java strictly separates numeric and boolean
types.
There is no implicit coercion,
and there are not even explicit casts.
int i = 0;
boolean b;
b = i; // illegal (no coercion)
b = (boolean)i; // illegal cast
As Section 4.2.5 of the Java Language Specification describes,
to convert a number to a boolean
,
one can use comparison operators:
if (i != 0) {
...
}