Get value from an Array
static Object get(Object array, int index)
- Returns the value of the indexed component in the specified array object.
static boolean getBoolean(Object array, int index)
- Returns array element as a boolean.
static byte getByte(Object array, int index)
- Returns array element as a byte.
static char getChar(Object array, int index)
- Returns array element as a char.
static double getDouble(Object array, int index)
- Returns array element as a double.
static float getFloat(Object array, int index)
- Returns array element as a float.
static int getInt(Object array, int index)
- Returns array element as an int.
static long getLong(Object array, int index)
- Returns array element as a long.
static short getShort(Object array, int index)
- Returns array element as a short.
import java.lang.reflect.Array;
import java.util.Arrays;
public class Main {
public static void main(String[] argv) throws Exception {
int[] array = { 1, 2, 3 };
// Get the value of the third element.
Object o = Array.get(array, 2);
System.out.println("o:"+o);
}
}
Home
Java Book
Reflection
Java Book
Reflection
Array:
- Array
- Get the length of an Array
- Get value from an Array
- Create new Array instance
- Set value to an Array