Class: java.lang.reflect.Array
- public final class Array
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.
Methods
-
gettop
public static native Object get(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionReturns 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. -
getBooleantop
public static native boolean getBoolean(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionReturns the value of the indexed component in the specified array object, as aboolean. -
getBytetop
public static native byte getByte(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionReturns the value of the indexed component in the specified array object, as abyte. -
getChartop
public static native char getChar(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionReturns the value of the indexed component in the specified array object, as achar. -
getDoubletop
public static native double getDouble(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionReturns the value of the indexed component in the specified array object, as adouble. -
getFloattop
public static native float getFloat(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionReturns the value of the indexed component in the specified array object, as afloat. -
getInttop
public static native int getInt(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionReturns the value of the indexed component in the specified array object, as anint. -
getLengthtop
public static native int getLength(Object array) throws IllegalArgumentExceptionReturns the length of the specified array object, as anint. -
getLongtop
public static native long getLong(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionReturns the value of the indexed component in the specified array object, as along. -
getShorttop
public static native short getShort(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionReturns the value of the indexed component in the specified array object, as ashort. -
newInstancetop
public static Object newInstance(Class<?> componentType, int length) throws NegativeArraySizeExceptionCreates 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); -
newInstancetop
public static Object newInstance(Class<?> componentType, int[] dimensions) throws IllegalArgumentException, NegativeArraySizeExceptionCreates a new array with the specified component type and dimensions. IfcomponentTyperepresents a non-array class or interface, the new array hasdimensions.lengthdimensions andcomponentTypeas its component type. IfcomponentTyperepresents an array class, the number of dimensions of the new array is equal to the sum ofdimensions.lengthand the number of dimensions ofcomponentType. In this case, the component type of the new array is the component type ofcomponentType.The number of dimensions of the new array must not exceed the number of array dimensions supported by the implementation (typically 255).
-
settop
public static native void set(Object array, int index, Object value) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionSets 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. -
setBooleantop
public static native void setBoolean(Object array, int index, boolean z) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionSets the value of the indexed component of the specified array object to the specifiedbooleanvalue. -
setBytetop
public static native void setByte(Object array, int index, byte b) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionSets the value of the indexed component of the specified array object to the specifiedbytevalue. -
setChartop
public static native void setChar(Object array, int index, char c) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionSets the value of the indexed component of the specified array object to the specifiedcharvalue. -
setDoubletop
public static native void setDouble(Object array, int index, double d) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionSets the value of the indexed component of the specified array object to the specifieddoublevalue. -
setFloattop
public static native void setFloat(Object array, int index, float f) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionSets the value of the indexed component of the specified array object to the specifiedfloatvalue. -
setInttop
public static native void setInt(Object array, int index, int i) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionSets the value of the indexed component of the specified array object to the specifiedintvalue. -
setLongtop
public static native void setLong(Object array, int index, long l) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionSets the value of the indexed component of the specified array object to the specifiedlongvalue. -
setShorttop
public static native void setShort(Object array, int index, short s) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionSets the value of the indexed component of the specified array object to the specifiedshortvalue.
