Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #input #string #list #java
ADD COMMENT
Topic
Name
6+5 =