java.lang
Class NullPointerException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.NullPointerException
public class NullPointerException
- extends RuntimeException
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.
NullPointerException
public NullPointerException()
- Create an exception without a message.
NullPointerException
public NullPointerException(String s)
- Create an exception with a message.
- Parameters:
s
- the message