Second, you can do the same things you would with the
null
literal, but considering the type:- Compare it to
null
or another variable of the same class. - Cast it to a parent type (upcast) or a subclass (downcast), considering the boundaries of generic parameters, if applicable.
- Access instance members and trigger a
NullPointerException
. - Apply
instanceof
, which will returnfalse
. - Pass it as a parameter to methods or use it in other operators compatible with the type.
NullPointerException
- but for the sake of debugging and to avoid confusion due to the lack of overriding for static members, it’s recommended not to do this. Instead, access statics explicitly through the class name or implicitly by adding import static
.