数组{1,3,5,7}和{2,4,6,8},要求合并数组,并升序排列

//数组{1,3,5,7}和{2,4,6,8}要求合并数组,并升序排列
public class Hbshuzu {
    public static void main(String[] args) {
        int a[] = {1,3,5,7};
        int b[] = {2,4,6,8};

        int c[] = new int[a.length + b.length];
        System.arraycopy(a,0,c,0,a.length);
        System.arraycopy(b,0,c,a.length,b.length);
        Arrays.sort(c);
        System.out.println(Arrays.toString(c));
    }
}

猜你喜欢

转载自blog.csdn.net/BO2345/article/details/125778464