Documentation  › java.lang.reflect  › Array
 
 


  Array
  public final

  Inherits From:   Object
  Conforms To:   none
  Declared In:   java.lang.reflect


Class Description
 
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.



Class Variables
 
None declared in this class.


Instance Variables
 
None declared in this class.


Constructors
 
None declared in this class.


Class Methods
 
get
public static native Object get( Object array, int index ) throws 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.


getBoolean
public static native boolean getBoolean( Object array, int index ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Returns the value of the indexed component in the specified array object, as a boolean.


getByte
public static native byte getByte( Object array, int index ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Returns the value of the indexed component in the specified array object, as a byte.


getChar
public static native char getChar( Object array, int index ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Returns the value of the indexed component in the specified array object, as a char.


getDouble
public static native double getDouble( Object array, int index ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Returns the value of the indexed component in the specified array object, as a double.


getFloat
public static native float getFloat( Object array, int index ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Returns the value of the indexed component in the specified array object, as a float.


getInt
public static native int getInt( Object array, int index ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Returns the value of the indexed component in the specified array object, as an int.


getLength
public static native int getLength( Object array ) throws IllegalArgumentException

Returns the length of the specified array object, as an int.


getLong
public static native long getLong( Object array, int index ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Returns the value of the indexed component in the specified array object, as a long.


getShort
public static native short getShort( Object array, int index ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Returns the value of the indexed component in the specified array object, as a short.


newInstance
public static Object newInstance( Class componentType, int length ) throws NegativeArraySizeException

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); 



newInstance
public static Object newInstance( Class componentType, int[] dimensions ) throws IllegalArgumentException, NegativeArraySizeException

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).


set
public static native void set( Object array, int index, Object value ) throws 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.


setBoolean
public static native void setBoolean( Object array, int index, boolean z ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Sets the value of the indexed component of the specified array object to the specified boolean value.


setByte
public static native void setByte( Object array, int index, byte b ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Sets the value of the indexed component of the specified array object to the specified byte value.


setChar
public static native void setChar( Object array, int index, char c ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Sets the value of the indexed component of the specified array object to the specified char value.


setDouble
public static native void setDouble( Object array, int index, double d ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Sets the value of the indexed component of the specified array object to the specified double value.


setFloat
public static native void setFloat( Object array, int index, float f ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Sets the value of the indexed component of the specified array object to the specified float value.


setInt
public static native void setInt( Object array, int index, int i ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Sets the value of the indexed component of the specified array object to the specified int value.


setLong
public static native void setLong( Object array, int index, long l ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Sets the value of the indexed component of the specified array object to the specified long value.


setShort
public static native void setShort( Object array, int index, short s ) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Sets the value of the indexed component of the specified array object to the specified short value.



Instance Methods
 
None declared in this class.


Known Subclasses
 
None.



 
 
  dydoc
  3/10/05