Click here to Skip to main content
15,908,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Want To Know Why This happens Bcz i Have Faced This Exception So many Times....

1 solution

There are many reasons. Refer - Class NullPointerException[^].
Thrown when an application attempts to use null in a
case where an object is required. These include:

  • Calling the instance method of a null object.
  • Accessing or modifying the field of a null object.
  • Taking the length of null as if it were an array.
  • Accessing or modifying the slots of null as if it
    were an array.
  • Throwing null as if it were a Throwable

Applications should throw instances of this class to indicate
other illegal uses of the null object. NullPointerException objects may be constructed by the virtual machine as if suppression were disabled and/or the
stack trace was not writable

Share this answer
RAVI _4378 25-Feb-14 0:29am    
it's Ok That i Know But Why NullPointer Instead of Null..
Okay. Can you please read Java null and NullPointerException[^]?

It is talking about that.
RAVI _4378 25-Feb-14 0:37am    
Thanks Got it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900