Android Guides | Samples

Java.Lang.Class.NewInstance Method

Returns a new instance of the class represented by this Class, created by invoking the default (that is, zero-argument) constructor.

Syntax

[Android.Runtime.Register("newInstance", "()Ljava/lang/Object;", "")]
public Object NewInstance ()

Exceptions

TypeReason
IllegalAccessExceptionif the default constructor is not visible.
InstantiationExceptionif the instance cannot be created.

Remarks

Returns a new instance of the class represented by this Class, created by invoking the default (that is, zero-argument) constructor. If there is no such constructor, or if the creation fails (either because of a lack of available memory or because an exception is thrown by the constructor), an InstantiationException is thrown. If the default constructor exists but is not accessible from the context where this method is invoked, an IllegalAccessException is thrown.

[Android Documentation]

Requirements

Namespace: Java.Lang
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1