Copy the content of an array (source) to another array (destination), beginning at the specified position, to the specified position of the destination array.
public static void arraycopy (Object source, int sourcePos, Object destination, int destPos, int length)
For example, the following code uses arraycopy to copy the contents of array1 to array2.
public class MainClass {
public static void main(String[] a) { int[] array1 = { 1, 2, 3, 4 }; int[] array2 = new int[array1.length];
System.arraycopy(array1, 0, array2, 0, array1.length);