Share via


Array.NewInstance Method

Definition

Overloads

NewInstance(Class, Int32[])

Creates a new array with the specified component type and dimensions.

NewInstance(Class, Int32)

Creates a new array with the specified component type and length.

NewInstance(Class, Int32[])

Creates a new array with the specified component type and dimensions.

[Android.Runtime.Register("newInstance", "(Ljava/lang/Class;[I)Ljava/lang/Object;", "")]
public static Java.Lang.Object NewInstance (Java.Lang.Class componentType, params int[]? dimensions);
[<Android.Runtime.Register("newInstance", "(Ljava/lang/Class;[I)Ljava/lang/Object;", "")>]
static member NewInstance : Java.Lang.Class * int[] -> Java.Lang.Object

Parameters

componentType
Class

the Class object representing the component type of the new array

dimensions
Int32[]

an array of int representing the dimensions of the new array

Returns

the new array

Attributes

Remarks

Creates a new array with the specified component type and dimensions. If componentType represents a non-array class or interface, the new array has dimensions.length dimensions and componentType as its component type. If componentType represents an array class, the number of dimensions of the new array is equal to the sum of dimensions.length and the number of dimensions of componentType. In this case, the component type of the new array is the component type of componentType.

The number of dimensions of the new array must not exceed 255.

Java documentation for java.lang.reflect.Array.newInstance(java.lang.Class<?>, int...).

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.

Applies to

NewInstance(Class, Int32)

Creates a new array with the specified component type and length.

[Android.Runtime.Register("newInstance", "(Ljava/lang/Class;I)Ljava/lang/Object;", "")]
public static Java.Lang.Object NewInstance (Java.Lang.Class componentType, int length);
[<Android.Runtime.Register("newInstance", "(Ljava/lang/Class;I)Ljava/lang/Object;", "")>]
static member NewInstance : Java.Lang.Class * int -> Java.Lang.Object

Parameters

componentType
Class

the Class object representing the component type of the new array

length
Int32

the length of the new array

Returns

the new array

Attributes

Remarks

Creates a new array with the specified component type and length. Invoking this method is equivalent to creating an array as follows: <blockquote>

int[] x = {length};
            Array.newInstance(componentType, x);

</blockquote>

The number of dimensions of the new array must not exceed 255.

Java documentation for java.lang.reflect.Array.newInstance(java.lang.Class<?>, int).

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.

Applies to