Array

The Array class provides static methods to dynamically create and access Java arrays.

Get the length of an Array

ReturnMethodSummary
static intgetLength(Object array)Returns the length of the specified array object, as an int.

Get value from an Array

ReturnMethodSummary
static Objectget(Object array, int index)Returns the value of the indexed component in the specified array object.
static booleangetBoolean(Object array, int index)Returns array element as a boolean.
static bytegetByte(Object array, int index)Returns array element as a byte.
static chargetChar(Object array, int index)Returns array element as a char.
static doublegetDouble(Object array, int index)Returns array element as a double.
static floatgetFloat(Object array, int index)Returns array element as a float.
static intgetInt(Object array, int index)Returns array element as an int.
static longgetLong(Object array, int index)Returns array element as a long.
static shortgetShort(Object array, int index)Returns array element as a short.

Create new Array instance

ReturnMethodSummary
static Object newInstance(Class<?> componentType, int... dimensions) Creates a new array with the component type and dimensions.
static Object newInstance(Class<?> componentType, int length) Creates a new array with the component type and length.

Set value to an Array

ReturnMethodSummary
static voidset(Object array, int index, Object value)Sets array element to the new value.
static voidsetBoolean(Object array, int index, boolean z)Sets array element to the boolean value.
static voidsetByte(Object array, int index, byte b)Sets array element to the byte value.
static voidsetChar(Object array, int index, char c)Sets array element to the char value.
static voidsetDouble(Object array, int index, double d)Sets array element to the double value.
static voidsetFloat(Object array, int index, float f)Sets array element to the float value.
static voidsetInt(Object array, int index, int i)Sets array element to the int value.
static voidsetLong(Object array, int index, long l)Sets array element to the long value.
static voidsetShort(Object array, int index, short s)Sets array element to the short value.
Revised from Open JDK source code
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.