Java Array.get(Object array, int index)
Syntax
Array.get(Object array, int index) has the following syntax.
public static Object get(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
Example
In the following code shows how to use Array.get(Object array, int index) method.
import java.lang.reflect.Array;
import java.util.Arrays;
/*w w w . j a va 2 s . c om*/
public class Main{
public static void main(String[] args) {
int[] sourceInts = { 12, 78 };
int[] destInts = new int[2];
for (int i = 0; i < Array.getLength(sourceInts); i++) {
Array.set(destInts, i, Array.get(sourceInts, i));
System.out.println(Array.get(destInts, i));
}
System.out.println(Arrays.toString(destInts));
}
}
The output: