|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.reflect.Array
public final class Array
Array provides methods to create instances of array and to access the elements of arrays of different types.
| Constructor Summary | |
|---|---|
Array()
|
|
| Method Summary | |
|---|---|
static Object |
get(Object array,
int index)
get returns the element of a given array at given index. |
static boolean |
getBoolean(Object array,
int index)
getBoolean returns the contents of a boolean array. |
static byte |
getByte(Object array,
int index)
getByte returns the contents of a byte array. |
static char |
getChar(Object array,
int index)
getChar returns the contents of a char array. |
static double |
getDouble(Object array,
int index)
getDouble returns the contents of a double array. |
static float |
getFloat(Object array,
int index)
getFloat returns the contents of a float array. |
static int |
getInt(Object array,
int index)
getInt returns the contents of a int array. |
static int |
getLength(Object array)
getLength returns the length of the given array instance. |
static long |
getLong(Object array,
int index)
getLong returns the contents of a long array. |
static short |
getShort(Object array,
int index)
getShort returns the contents of a short array. |
static Object |
newInstance(Class<?> componentType,
int length)
Create a new instance of an array with given component type and length. |
static Object |
newInstance(Class<?> componentType,
int[] dimensions)
newInstance |
static void |
set(Object a,
int i,
Object v)
set sets an array element to a a given value. |
static void |
setBoolean(Object array,
int index,
boolean z)
setBoolean sets an array element to a a given value. |
static void |
setByte(Object array,
int index,
byte b)
setByte sets an array element to a a given value. |
static void |
setChar(Object array,
int index,
char c)
setChar sets an array element to a a given value. |
static void |
setDouble(Object array,
int index,
double d)
setDouble sets an array element to a a given value. |
static void |
setFloat(Object array,
int index,
float f)
setFloat sets an array element to a a given value. |
static void |
setInt(Object array,
int index,
int i)
setInt sets an array element to a a given value. |
static void |
setLong(Object array,
int index,
long l)
setLong sets an array element to a a given value. |
static void |
setShort(Object array,
int index,
short s)
setShort sets an array element to a a given value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Array()
| Method Detail |
|---|
public static Object newInstance(Class<?> componentType,
int length)
throws NegativeArraySizeException,
IllegalArgumentException,
NullPointerException
componentType - the element type for the array. May be
either a normal class, an array or a primitive type such as
Boolean.TYPE, Byte.TYPE, etc.length - the number of elements for the new array.
NegativeArraySizeException - if length < 0
NullPointerException - if compontentType == null
IllegalArgumentException - if componentType == Void.TYPE
public static Object newInstance(Class<?> componentType,
int[] dimensions)
throws IllegalArgumentException,
NegativeArraySizeException
componentType - dimensions -
IllegalArgumentException
NegativeArraySizeException
public static int getLength(Object array)
throws IllegalArgumentException
array - instance of an array
IllegalArgumentException - if argument is not an array.
NullPointerException - if array is null.
public static Object get(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an arrayindex - an index in array
IllegalArgumentException - if array is not an array
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
NullPointerException - if array is null.
public static boolean getBoolean(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an array of boolean elements.index - an index in array
IllegalArgumentException - if the array is not of the
required type
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static byte getByte(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an array of boolean elements.index - an index in array
IllegalArgumentException - if the array is not of the
required type
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static char getChar(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an array of char elements.index - an index in array
IllegalArgumentException - if the array is not of the
required type
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static short getShort(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an array of short elements.index - an index in array
IllegalArgumentException - if the array is not of the
required type
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static int getInt(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an array of int elements.index - an index in array
IllegalArgumentException - if the array is not of the
required type
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static long getLong(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an array of long elements.index - an index in array
IllegalArgumentException - if the array is not of the
required type
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static float getFloat(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an array of float elements.index - an index in array
IllegalArgumentException - if the array is not of the
required type
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static double getDouble(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an array of double elements.index - an index in array
IllegalArgumentException - if the array is not of the
required type
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static void set(Object a,
int i,
Object v)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
a - an arrayi - the index to be setv - the value to be stored at the index
IllegalArgumentException - if array is not an array or
value could not be unboxed or converted to the array element
type.
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static void setBoolean(Object array,
int index,
boolean z)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an arrayindex - the index to be setz - the value to be stored at the index
IllegalArgumentException - if array is not an array or z
could not be converted to the array element type.
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static void setByte(Object array,
int index,
byte b)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an arrayindex - the index to be setb - the value to be stored at the index
IllegalArgumentException - if array is not an array or b
could not be converted to the array element type.
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static void setChar(Object array,
int index,
char c)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an arrayindex - the index to be setc - the value to be stored at the index
IllegalArgumentException - if array is not an array or c
could not be converted to the array element type.
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static void setShort(Object array,
int index,
short s)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an arrayindex - the index to be sets - the value to be stored at the index
IllegalArgumentException - if array is not an array or s
could not be converted to the array element type.
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static void setInt(Object array,
int index,
int i)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an arrayindex - the index to be seti - the value to be stored at the index
IllegalArgumentException - if array is not an array or i
could not be converted to the array element type.
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static void setLong(Object array,
int index,
long l)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an arrayindex - the index to be setl - the value to be stored at the index
IllegalArgumentException - if array is not an array or l
could not be converted to the array element type.
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static void setFloat(Object array,
int index,
float f)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an arrayindex - the index to be setf - the value to be stored at the index
IllegalArgumentException - if array is not an array or f
could not be converted to the array element type.
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
public static void setDouble(Object array,
int index,
double d)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
array - an arrayindex - the index to be setd - the value to be stored at the index
IllegalArgumentException - if array is not an array or d
could not be converted to the array element type.
NullPointerException - if array is null
ArrayIndexOutOfBoundsException - if index is negative or
larger than or equal to getLength(array).
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||