System.arraycopy()方法

 public static void main(String[] args) {
        int[] ints1 = {3, 4, 5, 6, 7, 8};
        int[] ints2 = new int[6];

        String ints1Str = "";
        for (int i : ints1) {
            ints1Str += i;
            ints1Str += ",";
        }
        System.out.println(ints1Str);
         /**
         * Object src:the source array. 源数组
         * int srcPos:starting position in the source array. 在源数组中,开始复制的位置
         * Object dest:the destination array. 目标数组
         * int destPos:starting position in the destination data. 在目标数组中,开始赋值的位置
         * int length:the number of array elements to be copied. 被复制的数组元素的数量
         */
        System.arraycopy(ints1, 0, ints2, 0, ints1.length);

        String ints2Str = "";
        for (int i : ints2) {
            ints2Str += i;
            ints2Str += ",";
        }
        System.out.println(ints2Str);
    }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值