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.
-
get(Object, int)
- Returns the value of the indexed component in the specified
array object.
-
getBoolean(Object, int)
- Returns the value of the indexed component in the specified
array object, as a boolean.
-
getByte(Object, int)
- Returns the value of the indexed component in the specified
array object, as a byte.
-
getChar(Object, int)
- Returns the value of the indexed component in the specified
array object, as a char.
-
getDouble(Object, int)
- Returns the value of the indexed component in the specified
array object, as a double.
-
getFloat(Object, int)
- Returns the value of the indexed component in the specified
array object, as a float.
-
getInt(Object, int)
- Returns the value of the indexed component in the specified
array object, as an int.
-
getLength(Object)
- Returns the length of the specified array object, as an int.
-
getLong(Object, int)
- Returns the value of the indexed component in the specified
array object, as a long.
-
getShort(Object, int)
- Returns the value of the indexed component in the specified
array object, as a short.
-
newInstance(Class, int)
- Creates a new array with the specified component type and
length.
-
newInstance(Class, int[])
- Creates a new array with the specified component type and
dimensions.
-
set(Object, int, Object)
- Sets the value of the indexed component of the specified array
object to the specified new value.
-
setBoolean(Object, int, boolean)
- Sets the value of the indexed component of the specified array
object to the specified boolean value.
-
setByte(Object, int, byte)
- Sets the value of the indexed component of the specified array
object to the specified boolean value.
-
setChar(Object, int, char)
- Sets the value of the indexed component of the specified array
object to the specified byte value.
-
setDouble(Object, int, double)
- Sets the value of the indexed component of the specified array
object to the specified double value.
-
setFloat(Object, int, float)
- Sets the value of the indexed component of the specified array
object to the specified float value.
-
setInt(Object, int, int)
- Sets the value of the indexed component of the specified array
object to the specified int value.
-
setLong(Object, int, long)
- Sets the value of the indexed component of the specified array
object to the specified long value.
-
setShort(Object, int, short)
- Sets the value of the indexed component of the specified array
object to the specified short value.
newInstance
method newInstance(componentType=Class, -
length=int) returns Object public static Signals 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
newInstance
method newInstance(componentType=Class, -
dimensions=int[]) returns Object public static Signals 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.
getLength
method getLength(array=Object) returns int public static Signals 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
get
method get(array=Object, -
index=int) returns Object public static Signals 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
getBoolean
method getBoolean(array=Object, -
index=int) returns boolean public static Signals 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
getByte
method getByte(array=Object, -
index=int) returns byte public static Signals 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
getChar
method getChar(array=Object, -
index=int) returns char public static Signals 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
getShort
method getShort(array=Object, -
index=int) returns short public static Signals 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
getInt
method getInt(array=Object, -
index=int) returns int public static Signals 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
getLong
method getLong(array=Object, -
index=int) returns long public static Signals 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
getFloat
method getFloat(array=Object, -
index=int) returns float public static Signals 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
getDouble
method getDouble(array=Object, -
index=int) returns double public static Signals 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
set
method set(array=Object, -
index=int, -
value=Object) public static Signals 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
setBoolean
method setBoolean(array=Object, -
index=int, -
z=boolean) public static Signals 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
setByte
method setByte(array=Object, -
index=int, -
b=byte) public static Signals 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
setChar
method setChar(array=Object, -
index=int, -
c=char) public static Signals 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
setShort
method setShort(array=Object, -
index=int, -
s=short) public static Signals 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
setInt
method setInt(array=Object, -
index=int, -
i=int) public static Signals 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
setLong
method setLong(array=Object, -
index=int, -
l=long) public static Signals 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
setFloat
method setFloat(array=Object, -
index=int, -
f=float) public static Signals 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
setDouble
method setDouble(array=Object, -
index=int, -
d=double) public static Signals 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