Top Description Fields Constructors Methods
java.lang

public Class NullPointerException

extends RuntimeException
Class Inheritance

Thrown when an application attempts to use null in a case where an object is required. These include:

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.

Since
1.0

Field Summary

Modifier and TypeField and Description
private transient String
private transient int
private static final long

Constructor Summary

AccessConstructor and Description
public
NullPointerException()

Constructs a NullPointerException with no detail message.

public
NullPointerException(String
the detail message.
s
)

Constructs a NullPointerException with the specified detail message.

Method Summary

Modifier and TypeMethod and Description
public synchronized Throwable
fillInStackTrace()

Overrides java.lang.Throwable.fillInStackTrace.

Fills in the execution stack trace.

private native String
getExtendedNPEMessage()

Get an extended exception message.

public String

Returns:

the detail message string, which may be null.
getMessage
()

Overrides java.lang.Throwable.getMessage.

Returns the detail message string of this throwable.

Field Detail

extendedMessageback to summary
private transient String extendedMessage
extendedMessageStateback to summary
private transient int extendedMessageState
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Annotations
@Serial

Constructor Detail

NullPointerExceptionback to summary
public NullPointerException()

Constructs a NullPointerException with no detail message.

NullPointerExceptionback to summary
public NullPointerException(String s)

Constructs a NullPointerException with the specified detail message.

Parameters
s:String

the detail message.

Method Detail

fillInStackTraceback to summary
public synchronized Throwable fillInStackTrace()

Overrides java.lang.Throwable.fillInStackTrace.

Doc from java.lang.Throwable.fillInStackTrace.

Fills in the execution stack trace. This method records within this Throwable object information about the current state of the stack frames for the current thread.

If the stack trace of this Throwable is not writable, calling this method has no effect.

Returns:Throwable

a reference to this Throwable instance.

getExtendedNPEMessageback to summary
private native String getExtendedNPEMessage()

Get an extended exception message. This returns a string describing the location and cause of the exception. It returns null for exceptions where this is not applicable.

getMessageback to summary
public String getMessage()

Overrides java.lang.Throwable.getMessage.

Returns the detail message string of this throwable.

If a non-null message was supplied in a constructor it is returned. Otherwise, an implementation specific message or null is returned.

Implementation Note

If no explicit message was passed to the constructor, and as long as certain internal information is available, a verbose description of the null reference is returned. The internal information is not available in deserialized NullPointerExceptions.

Returns:String

the detail message string, which may be null.