All Packages Class Hierarchy This Package Previous Next Index

Class java.lang.reflect.Array

java.lang.Object | +----java.lang.reflect.Array
public final class Array
extends Object
The Array class provides static methods to dynamically create and access Java arrays.

Array permits widening conversions to occur during a get or set operation, but throws an IllegalArgumentException if a narrowing conversion would occur.


Method Index

 o get(Object, int)
Returns the value of the indexed component in the specified array object.
 o getBoolean(Object, int)
Returns the value of the indexed component in the specified array object, as a boolean.
 o getByte(Object, int)
Returns the value of the indexed component in the specified array object, as a byte.
 o getChar(Object, int)
Returns the value of the indexed component in the specified array object, as a char.
 o getDouble(Object, int)
Returns the value of the indexed component in the specified array object, as a double.
 o getFloat(Object, int)
Returns the value of the indexed component in the specified array object, as a float.
 o getInt(Object, int)
Returns the value of the indexed component in the specified array object, as an int.
 o getLength(Object)
Returns the length of the specified array object, as an int.
 o getLong(Object, int)
Returns the value of the indexed component in the specified array object, as a long.
 o getShort(Object, int)
Returns the value of the indexed component in the specified array object, as a short.
 o newInstance(Class, int)
Creates a new array with the specified component type and length.
 o newInstance(Class, int[])
Creates a new array with the specified component type and dimensions.
 o set(Object, int, Object)
Sets the value of the indexed component of the specified array object to the specified new value.
 o setBoolean(Object, int, boolean)
Sets the value of the indexed component of the specified array object to the specified boolean value.
 o setByte(Object, int, byte)
Sets the value of the indexed component of the specified array object to the specified boolean value.
 o setChar(Object, int, char)
Sets the value of the indexed component of the specified array object to the specified byte value.
 o setDouble(Object, int, double)
Sets the value of the indexed component of the specified array object to the specified double value.
 o setFloat(Object, int, float)
Sets the value of the indexed component of the specified array object to the specified float value.
 o setInt(Object, int, int)
Sets the value of the indexed component of the specified array object to the specified int value.
 o setLong(Object, int, long)
Sets the value of the indexed component of the specified array object to the specified long value.
 o setShort(Object, int, short)
Sets the value of the indexed component of the specified array object to the specified short value.

Methods

 o newInstance public static Object newInstance(Class componentType, int length) throws NegativeArraySizeException
Creates a new array with the specified component type and length. The effect is that of the equivalent array creation expression: new componentType[length]

Parameters:
componentType - the Class object representing the component type of the new array
length - the length of the new array
Returns:
the new array
Throws: NullPointerException
if the specified componentType parameter is null
Throws: NegativeArraySizeException
if the specified length is negative
 o newInstance public static Object newInstance(Class componentType, int dimensions[]) throws IllegalArgumentException, NegativeArraySizeException
Creates a new array with the specified component type and dimensions.

The effect is that of the equivalent array creation expression: new componentType[dimensions[0]][dimensions[1]]...

Parameters:
componentType - the Class object representing the component type of the new array
dimensions - an array of ints representing the dimensions of the new array
Returns:
the new array
Throws: NullPointerException
if the specified componentType argument is null
Throws: IllegalArgumentException
if the specified dimensions argument is a zero-dimensional array, or if the number of requested dimensions exceeds the limit on the number of array dimensions supported by the implementation (typically 255).
Throws: NegativeArraySizeException
if any of the components in the specified dimension argument is negative.
 o getLength public static native int getLength(Object array) throws IllegalArgumentException
Returns the length of the specified array object, as an int.

Parameters:
array - the array
Returns:
the length of the array
Throws: IllegalArgumentException
if the object argument is not an array
 o get 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.

Parameters:
array - the array
index - the index
Returns:
the (possibly wrapped) value of the indexed component in the specified array
Throws: NullPointerException
If the specified object is null
Throws: IllegalArgumentException
If the specified object is not an array
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
 o getBoolean 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 boolean.

Parameters:
array - the array
index - the index
Returns:
the value of the indexed component in the specified array
Throws: NullPointerException
If the specified object is null
Throws: IllegalArgumentException
If the specified object is not an array, or if the indexed element cannot be converted to the return type by an identity or widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
get
 o getByte 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 byte.

Parameters:
array - the array
index - the index
Returns:
the value of the indexed component in the specified array
Throws: NullPointerException
If the specified object is null
Throws: IllegalArgumentException
If the specified object is not an array, or if the indexed element cannot be converted to the return type by an identity or widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
get
 o getChar 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 char.

Parameters:
array - the array
index - the index
Returns:
the value of the indexed component in the specified array
Throws: NullPointerException
If the specified object is null
Throws: IllegalArgumentException
If the specified object is not an array, or if the indexed element cannot be converted to the return type by an identity or widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
get
 o getShort 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 short.

Parameters:
array - the array
index - the index
Returns:
the value of the indexed component in the specified array
Throws: NullPointerException
If the specified object is null
Throws: IllegalArgumentException
If the specified object is not an array, or if the indexed element cannot be converted to the return type by an identity or widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
get
 o getInt 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 int.

Parameters:
array - the array
index - the index
Returns:
the value of the indexed component in the specified array
Throws: NullPointerException
If the specified object is null
Throws: IllegalArgumentException
If the specified object is not an array, or if the indexed element cannot be converted to the return type by an identity or widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
get
 o getLong 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 long.

Parameters:
array - the array
index - the index
Returns:
the value of the indexed component in the specified array
Throws: NullPointerException
If the specified object is null
Throws: IllegalArgumentException
If the specified object is not an array, or if the indexed element cannot be converted to the return type by an identity or widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
get
 o getFloat 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 float.

Parameters:
array - the array
index - the index
Returns:
the value of the indexed component in the specified array
Throws: NullPointerException
If the specified object is null
Throws: IllegalArgumentException
If the specified object is not an array, or if the indexed element cannot be converted to the return type by an identity or widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
get
 o getDouble 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 double.

Parameters:
array - the array
index - the index
Returns:
the value of the indexed component in the specified array
Throws: NullPointerException
If the specified object is null
Throws: IllegalArgumentException
If the specified object is not an array, or if the indexed element cannot be converted to the return type by an identity or widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
get
 o set 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.

Parameters:
array - the array
index - the index into the array
value - the new value of the indexed component
Throws: NullPointerException
If the specified object argument is null, or if the array component type is primitive and the specified value is null
Throws: IllegalArgumentException
If the specified object argument is not an array, or if the array component type is primitive and the specified value cannot be converted to the primitive type by a combination of unwrapping and identity or widening conversions
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
 o setBoolean 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 boolean value.

Parameters:
array - the array
index - the index into the array
value - the new value of the indexed component
Throws: NullPointerException
If the specified object argument is null
Throws: IllegalArgumentException
If the specified object argument is not an array, or if the the specified value cannot be converted to the underlying array's component type by an identity or a primitive widening widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
set
 o setByte 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 boolean value.

Parameters:
array - the array
index - the index into the array
value - the new value of the indexed component
Throws: NullPointerException
If the specified object argument is null
Throws: IllegalArgumentException
If the specified object argument is not an array, or if the the specified value cannot be converted to the underlying array's component type by an identity or a primitive widening widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
set
 o setChar 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 byte value.

Parameters:
array - the array
index - the index into the array
value - the new value of the indexed component
Throws: NullPointerException
If the specified object argument is null
Throws: IllegalArgumentException
If the specified object argument is not an array, or if the the specified value cannot be converted to the underlying array's component type by an identity or a primitive widening widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
set
 o setShort 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 short value.

Parameters:
array - the array
index - the index into the array
value - the new value of the indexed component
Throws: NullPointerException
If the specified object argument is null
Throws: IllegalArgumentException
If the specified object argument is not an array, or if the the specified value cannot be converted to the underlying array's component type by an identity or a primitive widening widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
set
 o setInt 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 int value.

Parameters:
array - the array
index - the index into the array
value - the new value of the indexed component
Throws: NullPointerException
If the specified object argument is null
Throws: IllegalArgumentException
If the specified object argument is not an array, or if the the specified value cannot be converted to the underlying array's component type by an identity or a primitive widening widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
set
 o setLong 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 long value.

Parameters:
array - the array
index - the index into the array
value - the new value of the indexed component
Throws: NullPointerException
If the specified object argument is null
Throws: IllegalArgumentException
If the specified object argument is not an array, or if the the specified value cannot be converted to the underlying array's component type by an identity or a primitive widening widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
set
 o setFloat 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 float value.

Parameters:
array - the array
index - the index into the array
value - the new value of the indexed component
Throws: NullPointerException
If the specified object argument is null
Throws: IllegalArgumentException
If the specified object argument is not an array, or if the the specified value cannot be converted to the underlying array's component type by an identity or a primitive widening widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
set
 o setDouble 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 double value.

Parameters:
array - the array
index - the index into the array
value - the new value of the indexed component
Throws: NullPointerException
If the specified object argument is null
Throws: IllegalArgumentException
If the specified object argument is not an array, or if the the specified value cannot be converted to the underlying array's component type by an identity or a primitive widening widening conversion
Throws: ArrayIndexOutOfBoundsException
If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
See Also:
set

All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature