Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to get single value from input string in java

public static void main(String[] args) {
    // TODO Auto-generated method stub

    Scanner reader = new Scanner(System.in);

    System.out.print("Enter the strings > ");
    String s1 = new String(reader.nextLine());

    String[] str = s1.split(" ");

    for(int i=1;i<str.length;i++){

        System.out.println(Integer.parseInt(str[i]));
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #single #input #string #java
ADD COMMENT
Topic
Name
5+8 =