同之处在于
Arrays.copyOf不仅复制元素,还创建新的数组。
System.arraycopy复制到现有阵列中。
这是的来源
Arrays.copyOf,你可以看到它在
System.arraycopy内部用于填充新数组:
public static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType) { T[] copy = ((Object)newType == (Object)Object[].class) ? (T[]) new Object[newLength] : (T[]) Array.newInstance(newType.getComponentType(), newLength); System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength)); return copy;}


