Answers for "input string a list in java"

0

input string a list in java

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<String> itemList = new ArrayList<String>(Arrays.asList(items));
    itemList.remove(0);
    Collections.sort(itemList);
    System.out.println(itemList);


} // End of main method
Posted by: Guest on October-10-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language