+ 3
What is NullPointerExeption?
4 Answers
+ 2
NullPointerException is a RuntimeException. In Java, a special null value can be assigned to an object reference. NullPointerException is thrown when an application attempts to use an object reference that has the null value. These include:
Calling an instance method on the object referred by a null reference.
Accessing or modifying an instance field of the object referred by a null reference.
If the reference type is an array type, taking the length of a null reference.
If the reference type is an array type, accessing or modifying the slots of a null reference.
If the reference type is a subtype of Throwable, throwing a null reference.
Applications should throw instances of this class to indicate other illegal uses of the null object.
https://en.wikibooks.org/wiki/Java_Programming/Preventing_NullPointerException
+ 2
You have your classes, which are basically blueprints for objects. Most often, you'll instantiate an object (create it from the blueprint so you can use it), and the associated variables/methods of that object are its instance variables/methods. It's relative to the object created. However, what if trying to do something with that object and it doesn't even exist? You're now pointing to a null value. NullPointerException.
+ 1
Netkos, please tell me what are " instance variables/methods " so that I can fully understand your answer. Thank you for your time.
+ 1
and what do you mean by "reference" as in " object reference"?