Java中数组的复制

标题日期:2020/1/14

标题功能:数组的复制

标题IDE:Intellij IDEA

package test.demo;

public class Test {
    public static void main(String[] args){
        int[] a = new int[3];
        a[0] = 1;
        a[1] = 2;
        a[2] = 3;
        int i;
        int[] b = new int[a.length];
        int[] c = new int[a.length];
        b = a.clone();
        System.arraycopy(a,0,c,0,a.length);
        for(i=0;i<b.length;i++)
            System.out.println(b[i]);
        for(i=0;i<c.length;i++)
            System.out.println(c[i]);
    }
}

发布了57 篇原创文章 · 获赞 2 · 访问量 1849

猜你喜欢

转载自blog.csdn.net/weixin_43476969/article/details/103968021