1.copy
public class Copy { public static void main(String[] args) { int[] a = {3,5,6,87,98,9}; System.out.println("------手工复制-------"); int[] b = new int[a.length]; for (int i=0;i<a.length;i++) { b[i] = a[i]; } System.out.println("-----Arrays.copyOf复制----"); //1参数:源数组,2参数:复制的长度,从0位置开始复制 int[] c = Arrays.copyOf(a, 4); for (int i : c) { System.out.println(i); } System.out.println("---System.arrayCopy-------"); int[] d = new int[10]; //源数组,源数组开始复制的索引位置,目标数组,目标数组的开始插入索引位置,要复制的长度 System.arraycopy(a,1, d, 3, 3); for (int i : d) { System.out.println(i); } } }