I am trying to make a boolean test so that if one of the tire pressures is below 35 or over 45 the system outputs \"bad inflation\".
In my class I must use a boolean, wh
Usually, code like if (variable = constantValue)
is treated as compilation error in Java. However, there is an exception when the constant value is a boolean. In that case, the statement is equal to if (constantValue)
. This kind of issue can not be found in the compilation phase.
So, I suggest 1)do not compare with boolean constant value, just do it by if (booleanVar)
;
2)always put the constant value ahead, like 'if (true = variable)' will cause the compilation fail.