The {@code Array} class provides static methods to dynamically create and
access Java arrays.
{@code Array} permits widening conversions to occur during a get or set
operation, but throws an {@code IllegalArgumentException} if a narrowing
conversion would occur.
| Method from java.lang.reflect.Array Detail: |
public static native Object get(Object array,
int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Returns the value of the indexed component in the specified
array object. The value is automatically wrapped in an object
if it has a primitive type. |
public static native boolean getBoolean(Object array,
int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Returns the value of the indexed component in the specified
array object, as a {@code boolean}. |
public static native byte getByte(Object array,
int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Returns the value of the indexed component in the specified
array object, as a {@code byte}. |
public static native char getChar(Object array,
int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Returns the value of the indexed component in the specified
array object, as a {@code char}. |
public static native double getDouble(Object array,
int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Returns the value of the indexed component in the specified
array object, as a {@code double}. |
public static native float getFloat(Object array,
int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Returns the value of the indexed component in the specified
array object, as a {@code float}. |
public static native int getInt(Object array,
int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Returns the value of the indexed component in the specified
array object, as an {@code int}. |
public static native int getLength(Object array) throws IllegalArgumentException
Returns the length of the specified array object, as an {@code int}. |
public static native long getLong(Object array,
int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Returns the value of the indexed component in the specified
array object, as a {@code long}. |
public static native short getShort(Object array,
int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Returns the value of the indexed component in the specified
array object, as a {@code short}. |
public static Object newInstance(Class componentType,
int length) throws NegativeArraySizeException {
return newArray(componentType, length);
}
|
public static Object newInstance(Class componentType,
int dimensions) throws IllegalArgumentException, NegativeArraySizeException {
return multiNewArray(componentType, dimensions);
}
Creates a new array
with the specified component type and dimensions.
If {@code componentType}
represents a non-array class or interface, the new array
has {@code dimensions.length} dimensions and
{@code componentType} as its component type. If
{@code componentType} represents an array class, the
number of dimensions of the new array is equal to the sum
of {@code dimensions.length} and the number of
dimensions of {@code componentType}. In this case, the
component type of the new array is the component type of
{@code componentType}.
The number of dimensions of the new array must not
exceed the number of array dimensions supported by the
implementation (typically 255). |
public static native void set(Object array,
int index,
Object value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Sets the value of the indexed component of the specified array
object to the specified new value. The new value is first
automatically unwrapped if the array has a primitive component
type. |
public static native void setBoolean(Object array,
int index,
boolean z) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Sets the value of the indexed component of the specified array
object to the specified {@code boolean} value. |
public static native void setByte(Object array,
int index,
byte b) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Sets the value of the indexed component of the specified array
object to the specified {@code byte} value. |
public static native void setChar(Object array,
int index,
char c) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Sets the value of the indexed component of the specified array
object to the specified {@code char} value. |
public static native void setDouble(Object array,
int index,
double d) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Sets the value of the indexed component of the specified array
object to the specified {@code double} value. |
public static native void setFloat(Object array,
int index,
float f) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Sets the value of the indexed component of the specified array
object to the specified {@code float} value. |
public static native void setInt(Object array,
int index,
int i) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Sets the value of the indexed component of the specified array
object to the specified {@code int} value. |
public static native void setLong(Object array,
int index,
long l) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Sets the value of the indexed component of the specified array
object to the specified {@code long} value. |
public static native void setShort(Object array,
int index,
short s) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Sets the value of the indexed component of the specified array
object to the specified {@code short} value. |