Answers for "how to get single value from input string in java"

0

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]));
    }
}
Posted by: Guest on November-11-2020

Code answers related to "how to get single value from input string in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language