Search
 
SCRIPT & CODE EXAMPLE
 

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]));
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: Get Max Value Element From List With Objects 
Java :: exception in thread "main" java.lang.arrayindexoutofboundsexception: 10 
Java :: how to do two constructors with super 
Java :: remove first character from string java 
Java :: factorial java recursion 
Java :: UIManager.setLookAndFeel Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke because "style" is null 
Java :: how to assign one value to 2 variable in one line in java 
Java :: add elements to arraylist of arraylist in java 
Java :: how to start java project in intellij 
Java :: spring-boot java header Content-Type constant 
Java :: how to fix this problem in java - Exception in thread "main" java.lang.IllegalArgumentException: input == null! at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1358) 
Java :: licenceurl 
Java :: https://javahungry.blogspot.com/2020/01/list-of-lists-in-java.html 
Java :: consumer 
Java :: how to generate randome number in desired range java 
Java :: how do you create a txt file in java 
Java :: import r android 
Java :: getarguments().getstring updates android 
Java :: Java Integer Literals 
Java :: java print color in console eclipse 
Java :: java fill two dimensional array stream 
Java :: mock dynamodb unit 
Java :: hierarchy inheritance gfg java 
Java :: int a[ ]={4,8,3,2}; a[0] = 23; a[3]= a[1]; a[2]=12; for(int i=0; i<a.length; i++) System.out.println(a[i]); 
Java :: gc algorithms java 8 
Java :: use scanner class in global scope java 
Java :: java @documented 
Java :: take string , double and int value from useer using java 
Java :: java boolean even number 
Java :: save logs tomcat java spring boot 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =