有时候想要用一下数组的复制和扩容操作,记录一下:
数组的复制:
int[] a = {1,2,3,4,5};
int[] a1 = {4,5,6,7,8,9};
System.arraycopy(a,1,a1,0,4);
[2,3,4,5,8,9]
数组的扩容
int[] a = {1,2,3,4,5};
a = Arrays.copy(a,a.length+1);
[1,2,3,4,5,0]
有时候想要用一下数组的复制和扩容操作,记录一下:
数组的复制:
int[] a = {1,2,3,4,5};
int[] a1 = {4,5,6,7,8,9};
System.arraycopy(a,1,a1,0,4);
[2,3,4,5,8,9]
数组的扩容
int[] a = {1,2,3,4,5};
a = Arrays.copy(a,a.length+1);
[1,2,3,4,5,0]