Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

When java doesn't support pointers. why does it throws null pointer exception?

user-image
Question added by varun reddy
Date Posted: 2015/08/26
Vittorio Cerioli
by Vittorio Cerioli , Teacher , ICS Villanterio (PV)

When you see "NullPointException", it means that you are using a variable that is not instantiated.

Zeron Aintablian
by Zeron Aintablian , Software Engineer / Architect , DC Soft S.A.L

Any Java variable you declare, then instantiate by the 'new' keyword, will "point" to a location in memory.  It is a reference to this location. NullPointerException is just a name, it could be anything.  When you try to use a variable which is NOT YET instantiated, it points nowhere and can do noting. hence the exception.

More Questions Like This