1. for循環(huán)
不多說,實現(xiàn)麻煩卓起,效率低。
2. System.arraycopy()
public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
推薦使用
3. Arrays.copyOf()
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;
}
內(nèi)部還是采用方法2實現(xiàn)