| java.lang.Object java.lang.reflect.Array
Array | final public class Array (Code) | | 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.
author: Nakul Saraiya
|
Method Summary | |
native public static Object | get(Object array, int index) Returns the value of the indexed component in the specified
array object. | native public static boolean | getBoolean(Object array, int index) Returns the value of the indexed component in the specified
array object, as a boolean . | native public static byte | getByte(Object array, int index) Returns the value of the indexed component in the specified
array object, as a byte . | native public static char | getChar(Object array, int index) Returns the value of the indexed component in the specified
array object, as a char . | native public static double | getDouble(Object array, int index) Returns the value of the indexed component in the specified
array object, as a double . | native public static float | getFloat(Object array, int index) Returns the value of the indexed component in the specified
array object, as a float . | native public static int | getInt(Object array, int index) Returns the value of the indexed component in the specified
array object, as an int . | native public static int | getLength(Object array) Returns the length of the specified array object, as an int . | native public static long | getLong(Object array, int index) Returns the value of the indexed component in the specified
array object, as a long . | native public static short | getShort(Object array, int index) Returns the value of the indexed component in the specified
array object, as a short . | public static Object | newInstance(Class componentType, int length) Creates a new array with the specified component type and
length. | public static Object | newInstance(Class componentType, int[] dimensions) Creates a new array
with the specified component type and dimensions. | native public static void | set(Object array, int index, Object value) Sets the value of the indexed component of the specified array
object to the specified new value. | native public static void | setBoolean(Object array, int index, boolean z) Sets the value of the indexed component of the specified array
object to the specified boolean value. | native public static void | setByte(Object array, int index, byte b) Sets the value of the indexed component of the specified array
object to the specified byte value. | native public static void | setChar(Object array, int index, char c) Sets the value of the indexed component of the specified array
object to the specified char value. | native public static void | setDouble(Object array, int index, double d) Sets the value of the indexed component of the specified array
object to the specified double value. | native public static void | setFloat(Object array, int index, float f) Sets the value of the indexed component of the specified array
object to the specified float value. | native public static void | setInt(Object array, int index, int i) Sets the value of the indexed component of the specified array
object to the specified int value. | native public static void | setLong(Object array, int index, long l) Sets the value of the indexed component of the specified array
object to the specified long value. | native public static void | setShort(Object array, int index, short s) Sets the value of the indexed component of the specified array
object to the specified short value. |
getBoolean | native public static boolean getBoolean(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Returns the value of the indexed component in the specified
array object, as a boolean .
Parameters: array - the array Parameters: index - the index the value of the indexed component in the specified array exception: NullPointerException - If the specified object is null exception: IllegalArgumentException - If the specified object is notan array, or if the indexed element cannot be converted to thereturn type by an identity or widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal to thelength of the specified array See Also: Array.get |
getByte | native public static byte getByte(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Returns the value of the indexed component in the specified
array object, as a byte .
Parameters: array - the array Parameters: index - the index the value of the indexed component in the specified array exception: NullPointerException - If the specified object is null exception: IllegalArgumentException - If the specified object is notan array, or if the indexed element cannot be converted to thereturn type by an identity or widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal to thelength of the specified array See Also: Array.get |
getChar | native public static char getChar(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Returns the value of the indexed component in the specified
array object, as a char .
Parameters: array - the array Parameters: index - the index the value of the indexed component in the specified array exception: NullPointerException - If the specified object is null exception: IllegalArgumentException - If the specified object is notan array, or if the indexed element cannot be converted to thereturn type by an identity or widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal to thelength of the specified array See Also: Array.get |
getDouble | native public static double getDouble(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Returns the value of the indexed component in the specified
array object, as a double .
Parameters: array - the array Parameters: index - the index the value of the indexed component in the specified array exception: NullPointerException - If the specified object is null exception: IllegalArgumentException - If the specified object is notan array, or if the indexed element cannot be converted to thereturn type by an identity or widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal to thelength of the specified array See Also: Array.get |
getFloat | native public static float getFloat(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Returns the value of the indexed component in the specified
array object, as a float .
Parameters: array - the array Parameters: index - the index the value of the indexed component in the specified array exception: NullPointerException - If the specified object is null exception: IllegalArgumentException - If the specified object is notan array, or if the indexed element cannot be converted to thereturn type by an identity or widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal to thelength of the specified array See Also: Array.get |
getInt | native public static int getInt(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Returns the value of the indexed component in the specified
array object, as an int .
Parameters: array - the array Parameters: index - the index the value of the indexed component in the specified array exception: NullPointerException - If the specified object is null exception: IllegalArgumentException - If the specified object is notan array, or if the indexed element cannot be converted to thereturn type by an identity or widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal to thelength of the specified array See Also: Array.get |
getLong | native public static long getLong(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Returns the value of the indexed component in the specified
array object, as a long .
Parameters: array - the array Parameters: index - the index the value of the indexed component in the specified array exception: NullPointerException - If the specified object is null exception: IllegalArgumentException - If the specified object is notan array, or if the indexed element cannot be converted to thereturn type by an identity or widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal to thelength of the specified array See Also: Array.get |
getShort | native public static short getShort(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Returns the value of the indexed component in the specified
array object, as a short .
Parameters: array - the array Parameters: index - the index the value of the indexed component in the specified array exception: NullPointerException - If the specified object is null exception: IllegalArgumentException - If the specified object is notan array, or if the indexed element cannot be converted to thereturn type by an identity or widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal to thelength of the specified array See Also: Array.get |
newInstance | public static Object newInstance(Class componentType, int length) throws NegativeArraySizeException(Code) | | Creates a new array with the specified component type and
length.
Invoking this method is equivalent to creating an array
as follows:
int[] x = {length};
Array.newInstance(componentType, x);
Parameters: componentType - the Class object representing thecomponent type of the new array Parameters: length - the length of the new array the new array exception: NullPointerException - if the specifiedcomponentType parameter is null exception: IllegalArgumentException - if componentType is Void.TYPE exception: NegativeArraySizeException - if the specified length is negative |
newInstance | public static Object newInstance(Class componentType, int[] dimensions) throws IllegalArgumentException, NegativeArraySizeException(Code) | | 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 the number of array dimensions supported by the
implementation (typically 255).
Parameters: componentType - the Class object representing the componenttype of the new array Parameters: dimensions - an array of int types representing the dimensions ofthe new array the new array exception: NullPointerException - if the specified componentType argument is null exception: IllegalArgumentException - if the specified dimensions argument is a zero-dimensional array, or if the number ofrequested dimensions exceeds the limit on the number of array dimensions supported by the implementation (typically 255), or if componentType is Void.TYPE. exception: NegativeArraySizeException - if any of the components inthe specified dimensions argument is negative. |
set | native public static void set(Object array, int index, Object value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | 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 Parameters: index - the index into the array Parameters: value - the new value of the indexed component exception: NullPointerException - If the specified object argumentis null, or if the array component type is primitive and the specifiedvalue is null exception: IllegalArgumentException - If the specified object argumentis not an array, or if the array component type is primitive andthe specified value cannot be converted to the primitive type bya combination of unwrapping and identity or widening conversions exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal tothe length of the specified array |
setBoolean | native public static void setBoolean(Object array, int index, boolean z) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Sets the value of the indexed component of the specified array
object to the specified boolean value.
Parameters: array - the array Parameters: index - the index into the array Parameters: z - the new value of the indexed component exception: NullPointerException - If the specified object argumentis null exception: IllegalArgumentException - If the specified object argumentis not an array, or if the the specified value cannot be convertedto the underlying array's component type by an identity or aprimitive widening widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal tothe length of the specified array See Also: Array.set |
setByte | native public static void setByte(Object array, int index, byte b) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Sets the value of the indexed component of the specified array
object to the specified byte value.
Parameters: array - the array Parameters: index - the index into the array Parameters: b - the new value of the indexed component exception: NullPointerException - If the specified object argumentis null exception: IllegalArgumentException - If the specified object argumentis not an array, or if the the specified value cannot be convertedto the underlying array's component type by an identity or aprimitive widening widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal tothe length of the specified array See Also: Array.set |
setChar | native public static void setChar(Object array, int index, char c) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Sets the value of the indexed component of the specified array
object to the specified char value.
Parameters: array - the array Parameters: index - the index into the array Parameters: c - the new value of the indexed component exception: NullPointerException - If the specified object argumentis null exception: IllegalArgumentException - If the specified object argumentis not an array, or if the the specified value cannot be convertedto the underlying array's component type by an identity or aprimitive widening widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal tothe length of the specified array See Also: Array.set |
setDouble | native public static void setDouble(Object array, int index, double d) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Sets the value of the indexed component of the specified array
object to the specified double value.
Parameters: array - the array Parameters: index - the index into the array Parameters: d - the new value of the indexed component exception: NullPointerException - If the specified object argumentis null exception: IllegalArgumentException - If the specified object argumentis not an array, or if the the specified value cannot be convertedto the underlying array's component type by an identity or aprimitive widening widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal tothe length of the specified array See Also: Array.set |
setFloat | native public static void setFloat(Object array, int index, float f) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Sets the value of the indexed component of the specified array
object to the specified float value.
Parameters: array - the array Parameters: index - the index into the array Parameters: f - the new value of the indexed component exception: NullPointerException - If the specified object argumentis null exception: IllegalArgumentException - If the specified object argumentis not an array, or if the the specified value cannot be convertedto the underlying array's component type by an identity or aprimitive widening widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal tothe length of the specified array See Also: Array.set |
setInt | native public static void setInt(Object array, int index, int i) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Sets the value of the indexed component of the specified array
object to the specified int value.
Parameters: array - the array Parameters: index - the index into the array Parameters: i - the new value of the indexed component exception: NullPointerException - If the specified object argumentis null exception: IllegalArgumentException - If the specified object argumentis not an array, or if the the specified value cannot be convertedto the underlying array's component type by an identity or aprimitive widening widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal tothe length of the specified array See Also: Array.set |
setLong | native public static void setLong(Object array, int index, long l) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Sets the value of the indexed component of the specified array
object to the specified long value.
Parameters: array - the array Parameters: index - the index into the array Parameters: l - the new value of the indexed component exception: NullPointerException - If the specified object argumentis null exception: IllegalArgumentException - If the specified object argumentis not an array, or if the the specified value cannot be convertedto the underlying array's component type by an identity or aprimitive widening widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal tothe length of the specified array See Also: Array.set |
setShort | native public static void setShort(Object array, int index, short s) throws IllegalArgumentException, ArrayIndexOutOfBoundsException(Code) | | Sets the value of the indexed component of the specified array
object to the specified short value.
Parameters: array - the array Parameters: index - the index into the array Parameters: s - the new value of the indexed component exception: NullPointerException - If the specified object argumentis null exception: IllegalArgumentException - If the specified object argumentis not an array, or if the the specified value cannot be convertedto the underlying array's component type by an identity or aprimitive widening widening conversion exception: ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal tothe length of the specified array See Also: Array.set |
|
|