newArray method (format 2)

Description

Directly creates an array instance with a dimension dimensions.length in the Explicit memory block indicated by the object. Note that the number of elements of the nth dimension of the class indicated by the parameter type is dimensions[n-1].

Format

public Object newArray(Class type,  int[] dimensions);

Parameters

type:
This parameter specifies the class of the array instance to be created directly.
dimensions:
This parameter specifies the number of dimensions and elements of the array instance to be created directly.

Exceptions

NullPointerException:
The value of either one or both the parameters dimensions and type is null.
NegativeArraySizeException:
The parameter dimension has an element with a negative value.
IllegalArgumentException:
This exception is thrown in any of the following cases:
  • When dimensions.length of the parameter dimensions is less than 0 or more than 255
  • When the total of the number of dimensions of the parameter type and dimensions.length of the parameter dimensions is more than 255
  • When the parameter type is Void.TYPE
InaccessibleMemoryAreaException:
This functionality is not supported.

Return value

This method directly creates an array object with the dimension dimensions.length and the type type, wherein the number of elements of the nth dimension is dimensions[n-1], in the Explicit memory block indicated by the object, and then returns the reference.

If it is judged that processing cannot be executed by performing the common error check, invoke java.lang.reflect.Array.newInstance (Class<?> componentType,int[] dimensions) by the parameter type and parameter dimensions, and return that result. For details on common error check, see 10.6 Error check (common error check) of the process that controls the Explicit memory block .