动态数组求解

import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s1 = in.nextLine();
        String[] num1 = s1.split(",");
        if(!in.hasNext()){
            System.out.print(s1);
            return;
        }
        String s2 = in.nextLine();
        String[] num2 = s2.split(",");
        List<Integer> list = new ArrayList<>();
        for(String i : num1) {
            list.add(Integer.valueOf(i));
        }
        for(String i : num2) {
            list.add(Integer.valueOf(i));
        }
        int[] res = new int[num1.length+num2.length];
        for(int i=0;i<res.length;i++){
            res[i]=list.get(i);
        }
        Arrays.sort(res);
        int k = 0;
        while(k<res.length){
            System.out.print(res[k]);
            if(k!=res.length-1){
                System.out.print(",");
            }
            k++;
        }
    }
}