Java – Check if null Boolean is true results in exception


I have the following code:

Boolean bool = null;

    if (bool)
catch (Exception e) 

Why does my check up on the Boolean variable "bool" result in an exception?
Shouldn't it just jump right past the if statement when it "sees" that it isn't true?
When I remove the if statement or check up on if it's NOT null, the exception goes away.

Best Solution

If you don't like extra null checks:

if (Boolean.TRUE.equals(value)) {...}