The first form, when used with an API that returns Boolean
and compared against Boolean.FALSE, will never throw a NullPointerException
.
The second form, when used with the java.util.Map
interface, also, will never throw a NullPointerException
because it returns a boolean
and not a Boolean
.
If you aren't concerned about consistent coding idioms, then you can pick the one you like, and in this concrete case it really doesn't matter. If you do care about consistent coding, then consider what you want to do when you check a Boolean
that may be NULL
.