博客> java arraycopy()
java arraycopy()
2019-07-17 01:29 评论:0 阅读:65 IT喃
ios

java arraycopy()

System.arraycopy()


System.arraycopy(digest, index1, frame, index2, digest.length);

// 把digest中的内容从第index1个开始复制到frame中去,从frame的第index2开始,总共要复制的长度为 digest.length
public class Main {

    public static void main(String[] args) {

        String[] names = new String[] { "A", "B", "C" };

        String[] extended = new String[5];

        extended[3] = "D";

        extended[4] = "E";

        System.arraycopy(names, 0, extended, 0, names.length);

        for (String str : extended){

            System.out.println(str);

        }

    }

}

运行结果:

A

B

C

D

E

上面的例子引用自https://www.runoob.com/ ,如有侵权,请联系作者删除

收藏
0
sina weixin mail 回到顶部