Module java.base
Package java.lang.reflect

Class Array


  • public final classArrayextendsObject
    TheArray 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 anIllegalArgumentException if a narrowing conversion would occur.

    Since:
    1.1
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethodDescription
      staticObjectget​(Object array, int index)
      Returns the value of the indexed component in the specified array object.
      static booleangetBoolean​(Object array, int index)
      Returns the value of the indexed component in the specified array object, as aboolean.
      static bytegetByte​(Object array, int index)
      Returns the value of the indexed component in the specified array object, as abyte.
      static chargetChar​(Object array, int index)
      Returns the value of the indexed component in the specified array object, as achar.
      static doublegetDouble​(Object array, int index)
      Returns the value of the indexed component in the specified array object, as adouble.
      static floatgetFloat​(Object array, int index)
      Returns the value of the indexed component in the specified array object, as afloat.
      static intgetInt​(Object array, int index)
      Returns the value of the indexed component in the specified array object, as anint.
      static intgetLength​(Object array)
      Returns the length of the specified array object, as anint.
      static longgetLong​(Object array, int index)
      Returns the value of the indexed component in the specified array object, as along.
      static shortgetShort​(Object array, int index)
      Returns the value of the indexed component in the specified array object, as ashort.
      staticObjectnewInstance​(Class<?> componentType, int length)
      Creates a new array with the specified component type and length.
      staticObjectnewInstance​(Class<?> componentType, int... dimensions)
      Creates a new array with the specified component type and dimensions.
      static voidset​(Object array, int index,Object value)
      Sets the value of the indexed component of the specified array object to the specified new value.
      static voidsetBoolean​(Object array, int index, boolean z)
      Sets the value of the indexed component of the specified array object to the specifiedboolean value.
      static voidsetByte​(Object array, int index, byte b)
      Sets the value of the indexed component of the specified array object to the specifiedbyte value.
      static voidsetChar​(Object array, int index, char c)
      Sets the value of the indexed component of the specified array object to the specifiedchar value.
      static voidsetDouble​(Object array, int index, double d)
      Sets the value of the indexed component of the specified array object to the specifieddouble value.
      static voidsetFloat​(Object array, int index, float f)
      Sets the value of the indexed component of the specified array object to the specifiedfloat value.
      static voidsetInt​(Object array, int index, int i)
      Sets the value of the indexed component of the specified array object to the specifiedint value.
      static voidsetLong​(Object array, int index, long l)
      Sets the value of the indexed component of the specified array object to the specifiedlong value.
      static voidsetShort​(Object array, int index, short s)
      Sets the value of the indexed component of the specified array object to the specifiedshort value.