how to get single value from input string in java

Solutions on MaxInterview for how to get single value from input string in java by the best coders in the world

showing results for - "how to get single value from input string in java"
Juan
23 Jun 2019
1public static void main(String[] args) {
2    // TODO Auto-generated method stub
3
4    Scanner reader = new Scanner(System.in);
5
6    System.out.print("Enter the strings > ");
7    String s1 = new String(reader.nextLine());
8
9    String[] str = s1.split(" ");
10
11    for(int i=1;i<str.length;i++){
12
13        System.out.println(Integer.parseInt(str[i]));
14    }
15}
16
similar questions