system.arraycopy是复制数组中制定元素到目标数组,
arrays.copyof会创建一个新的数组,并调用了system.arraycopy,具体见源码
public static int[] copyOf(int[] original, int newLength) {
int[] copy = new int[newLength];
System.arraycopy(original, 0, copy, 0,
Math.min(original.length, newLength));
return copy;
}
关键点,arrays.copyof会从创建一个新的数组,而system.arraycopy只是复制数组的功能,单独的他不会创建新的数组。