1.前言。
Arrays.copyof底层也是用System.arraycopy的,所以只有一维的数组拷贝,直接用System.arraycopy就可以了。
2.代码。
Arrays.copyof底层也是用System.arraycopy的,所以只有一维的数组拷贝,直接用System.arraycopy就可以了。
2.代码。
import java.util.Arrays;
public class Test {
public static void main(String[] args) {
byte[] a=new byte[3];
a[0]=1;
a[1]=2;
byte[] b=new byte[]{4,5};
byte[] c=new byte[a.length+b.length];
System.arraycopy(a, 0, c, 0, a.length);
System.arraycopy(b, 0, c, a.length, b.length);
//System.arraycopy(b, 1, c, 0, b.length);
System.out.println(Arrays.toString(c));
}
}