1int[] src = new int[]{1,2,3,4,5};
2int[] dest = new int[5];
3
4System.arraycopy( src, 0, dest, 0, src.length );
1// method
2public static int [] copyArray(int [] arr){
3 int [] copyArr = new int[arr.length];
4 for (int i = 0; i < copyArr.length; i++){
5 copyArr[i] = arr[i];
6 }
7 return copyArr;
8}
9
10// Arrays. method
11int[] copyCat = Arrays.copyOf(arr, arr.length);
12
13// System
14System.arraycopy(x,0,y,0,5); // 5 is array's length
15
16// clone
17y = x.clone();
1// A Java program to demonstrate array copy using clone()
2public class Test {
3 public static void main(String[] args)
4 {
5 int a[] = { 1, 8, 3 };
6 int b[] = a.clone();
7 }
8}
9