Why it throws null pointer exception when object is initialized to null and then trying to access class method? [duplicate]

The NullPointerException means you tried to deference a null value so you get the expected behaviour.

It doesn’t have anything to do with detecting uninitialised values. It’s not called UninitialisedException

Leave a Comment