📜  在java代码示例中输入字符串列表

📅  最后修改于: 2022-03-11 14:52:09.954000             🧑  作者: Mango

代码示例1
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.Arrays;

public static void main(String[] args) {
    Scanner input = new Scanner(System.in);

    System.out.println("Insert the first series of numbers: ");
    String number1 = input.nextLine();
    System.out.println("Insert the second series of numbers: ");
    String number2 = input.nextLine();

    String[] items = number1.split(" ");
    String[] items2 = number2.split (" ");

    List itemList = new ArrayList(Arrays.asList(items));
    itemList.remove(0);
    Collections.sort(itemList);
    System.out.println(itemList);


} // End of main method