public final class Array extends Object
| Modifier and Type | Method and Description |
|---|---|
static Object |
get(Object array,
int index)
Returns the element of the array at the specified index.
|
static boolean |
getBoolean(Object array,
int index)
Returns the boolean at the given index in the given boolean array.
|
static byte |
getByte(Object array,
int index)
Returns the byte at the given index in the given byte array.
|
static char |
getChar(Object array,
int index)
Returns the char at the given index in the given char array.
|
static double |
getDouble(Object array,
int index)
Returns the double at the given index in the given array.
|
static float |
getFloat(Object array,
int index)
Returns the float at the given index in the given array.
|
static int |
getInt(Object array,
int index)
Returns the int at the given index in the given array.
|
static int |
getLength(Object array)
Returns the length of the array.
|
static long |
getLong(Object array,
int index)
Returns the long at the given index in the given array.
|
static short |
getShort(Object array,
int index)
Returns the short at the given index in the given array.
|
static Object |
newInstance(Class<?> componentType,
int... dimensions)
Returns a new multidimensional array of the specified component type and
dimensions.
|
static Object |
newInstance(Class<?> componentType,
int size)
Returns a new array of the specified component type and length.
|
static void |
set(Object array,
int index,
Object value)
Sets the element of the array at the specified index to the value.
|
static void |
setBoolean(Object array,
int index,
boolean value)
Sets
array[index] = value. |
static void |
setByte(Object array,
int index,
byte value)
Sets
array[index] = value. |
static void |
setChar(Object array,
int index,
char value)
Sets
array[index] = value. |
static void |
setDouble(Object array,
int index,
double value)
Sets
array[index] = value. |
static void |
setFloat(Object array,
int index,
float value)
Sets
array[index] = value. |
static void |
setInt(Object array,
int index,
int value)
Sets
array[index] = value. |
static void |
setLong(Object array,
int index,
long value)
Sets
array[index] = value. |
static void |
setShort(Object array,
int index,
short value)
Sets
array[index] = value. |
public static Object get(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
array[index].
If the array component is a primitive type, the result is automatically boxed.NullPointerException - if array == nullIllegalArgumentException - if array is not an arrayArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static boolean getBoolean(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
NullPointerException - if array == nullIllegalArgumentException - if array is not an array or the element at the
index position can not be converted to the return typeArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static byte getByte(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
NullPointerException - if array == nullIllegalArgumentException - if array is not an array or the element at the
index position can not be converted to the return typeArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static char getChar(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
NullPointerException - if array == nullIllegalArgumentException - if array is not an array or the element at the
index position can not be converted to the return typeArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static double getDouble(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
NullPointerException - if array == nullIllegalArgumentException - if array is not an array or the element at the
index position can not be converted to the return typeArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static float getFloat(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
NullPointerException - if array == nullIllegalArgumentException - if array is not an array or the element at the
index position can not be converted to the return typeArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static int getInt(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
NullPointerException - if array == nullIllegalArgumentException - if array is not an array or the element at the
index position can not be converted to the return typeArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static int getLength(Object array)
array.length.NullPointerException - if array == nullIllegalArgumentException - if array is not an arraypublic static long getLong(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
NullPointerException - if array == nullIllegalArgumentException - if array is not an array or the element at the
index position can not be converted to the return typeArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static short getShort(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
NullPointerException - if array == nullIllegalArgumentException - if array is not an array or the element at the
index position can not be converted to the return typeArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static Object newInstance(Class<?> componentType, int... dimensions) throws NegativeArraySizeException, IllegalArgumentException
new componentType[d0][d1]...[dn] for a
dimensions array of { d0, d1, ... , dn }.NullPointerException - if array == nullNegativeArraySizeException - if any of the dimensions are negativeIllegalArgumentException - if the array of dimensions is of size zero, or exceeds the
limit of the number of dimension for an array (currently 255)public static Object newInstance(Class<?> componentType, int size) throws NegativeArraySizeException
new componentType[size].NullPointerException - if the component type is nullNegativeArraySizeException - if size < 0public static void set(Object array, int index, Object value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
array[index] = value. If the array
component is a primitive type, the value is automatically unboxed.NullPointerException - if array == nullIllegalArgumentException - if array is not an array or the value cannot be
converted to the array type by a widening conversionArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static void setBoolean(Object array, int index, boolean value)
array[index] = value. Applies to boolean arrays.NullPointerException - if array == nullIllegalArgumentException - if the array is not an array or the value cannot be
converted to the array type by a widening conversionArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static void setByte(Object array, int index, byte value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
array[index] = value. Applies to byte, double, float, int, long, and short arrays.NullPointerException - if array == nullIllegalArgumentException - if the array is not an array or the value cannot be
converted to the array type by a widening conversionArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static void setChar(Object array, int index, char value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
array[index] = value. Applies to char, double, float, int, and long arrays.NullPointerException - if array == nullIllegalArgumentException - if the array is not an array or the value cannot be
converted to the array type by a widening conversionArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static void setDouble(Object array, int index, double value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
array[index] = value. Applies to double arrays.NullPointerException - if array == nullIllegalArgumentException - if the array is not an array or the value cannot be
converted to the array type by a widening conversionArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static void setFloat(Object array, int index, float value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
array[index] = value. Applies to double and float arrays.NullPointerException - if array == nullIllegalArgumentException - if the array is not an array or the value cannot be
converted to the array type by a widening conversionArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static void setInt(Object array, int index, int value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
array[index] = value. Applies to double, float, int, and long arrays.NullPointerException - if array == nullIllegalArgumentException - if the array is not an array or the value cannot be
converted to the array type by a widening conversionArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static void setLong(Object array, int index, long value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
array[index] = value. Applies to double, float, and long arrays.NullPointerException - if array == nullIllegalArgumentException - if the array is not an array or the value cannot be
converted to the array type by a widening conversionArrayIndexOutOfBoundsException - if index < 0 || index >= array.lengthpublic static void setShort(Object array, int index, short value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
array[index] = value. Applies to double, float, int, long, and short arrays.NullPointerException - if array == nullIllegalArgumentException - if the array is not an array or the value cannot be
converted to the array type by a widening conversionArrayIndexOutOfBoundsException - if index < 0 || index >= array.length