Hello, numeric values cannot be assigned to booleans in Java (e.g. boolean b = 100; gives an "incompatible types" compiler error). Why then does this piece of code compile fine and print true:
'b', 'B' general If the argument arg is null, then the result is "false". If arg is a boolean or Boolean, then the result is the string returned by String.valueOf(). Otherwise, the result is "true".
There is definitely an inconsistency in the way that %b works in printf/format statements verses the way booleans work in the rest of Java. This seems to violate the "least surprise" principal. I'm also not crazy about the implementation of Boolean. It's full of surprises too.
I think the way boolean is implemented by Java is great. Much better than C/C++. A boolean is just true or false. I wish Java had stuck with that kind of simple implementation with Boolean and %b!