Thrown when attempting to use
null
where an object
is required. The Virtual Machine automatically throws this exception
for the following:
- Calling an instance method on a null object
- Accessing or modifying a field of a null object
- Taking the array length of a null array
- Accessing or modifying the slots of a null array
- Throwing a null Throwable
- Synchronizing on a null object
Applications should also throw NullPointerExceptions whenever
null
is an inappropriate parameter to a method.
Create an exception without a message.
Create an exception with a message.
null
where an object is required. The Virtual Machine automatically throws this exception for the following:Applications should also throw NullPointerExceptions whenever
null
is an inappropriate parameter to a method.