System.arraycopy用法

System.arraycopy用法

注意长度的设置;

public class ArrCopy {
    public static void main(String[] args) {
        int [] src = {1,2,3,4,5,6,7,8,9,10};
        int [] src2 = {1,2,3,4,5,6,7,8,9,10};
        int [] dest = new int[20];
        System.arraycopy(src, 0, dest, 0, 10);
        System.arraycopy(src2, 0, dest, 10, 10);
        System.out.println(Arrays.toString(dest));
    }
}
原文地址:https://www.cnblogs.com/stono/p/6872509.html