Compartilhar via


NullPointerException Class

Definition

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

[Android.Runtime.Register("java/lang/NullPointerException", DoNotGenerateAcw=true)]
public class NullPointerException : Java.Lang.RuntimeException
[<Android.Runtime.Register("java/lang/NullPointerException", DoNotGenerateAcw=true)>]
type NullPointerException = class
    inherit RuntimeException
Inheritance
Attributes

Remarks

Thrown when an application attempts to use null in a case where an object is required. These include: <ul> <li>Calling the instance method of a null object. <li>Accessing or modifying the field of a null object. <li>Taking the length of null as if it were an array. <li>Accessing or modifying the slots of null as if it were an array. <li>Throwing null as if it were a Throwable value. </ul>

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 Throwable#Throwable(String, Throwable, boolean, boolean) suppression were disabled and/or the stack trace was not writable.

Added in 1.0.

Java documentation for java.lang.NullPointerException.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

NullPointerException()

Constructs a NullPointerException with no detail message.

NullPointerException(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

NullPointerException(String)

Constructs a NullPointerException with the specified detail message.

Fields

is_generated (Inherited from Throwable)

Properties

Cause

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

(Inherited from Throwable)
Class (Inherited from Throwable)
Handle

The handle to the underlying Android instance.

(Inherited from Throwable)
JniIdentityHashCode (Inherited from Throwable)
JniPeerMembers
LocalizedMessage

Creates a localized description of this throwable.

(Inherited from Throwable)
Message

Returns the detail message string of this throwable.

(Inherited from Throwable)
PeerReference (Inherited from Throwable)
StackTrace (Inherited from Throwable)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

AddSuppressed(Throwable)

Appends the specified exception to the exceptions that were suppressed in order to deliver this exception.

(Inherited from Throwable)
Dispose() (Inherited from Throwable)
Dispose(Boolean) (Inherited from Throwable)
FillInStackTrace()

Fills in the execution stack trace.

(Inherited from Throwable)
GetStackTrace()

Provides programmatic access to the stack trace information printed by #printStackTrace().

(Inherited from Throwable)
GetSuppressed()

Returns an array containing all of the exceptions that were suppressed, typically by the try-with-resources statement, in order to deliver this exception.

(Inherited from Throwable)
InitCause(Throwable)

Initializes the cause of this throwable to the specified value.

(Inherited from Throwable)
PrintStackTrace()

Prints this throwable and its backtrace to the standard error stream.

(Inherited from Throwable)
PrintStackTrace(PrintStream)

Prints this throwable and its backtrace to the specified print stream.

(Inherited from Throwable)
PrintStackTrace(PrintWriter)

Prints this throwable and its backtrace to the specified print writer.

(Inherited from Throwable)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Throwable)
SetStackTrace(StackTraceElement[])

Sets the stack trace elements that will be returned by #getStackTrace() and printed by #printStackTrace() and related methods.

(Inherited from Throwable)
ToString() (Inherited from Throwable)
UnregisterFromRuntime() (Inherited from Throwable)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Throwable)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Throwable)
IJavaPeerable.Finalized() (Inherited from Throwable)
IJavaPeerable.JniManagedPeerState (Inherited from Throwable)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Throwable)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Throwable)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Throwable)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to