Issue
i wish to read multiple inputs on a single line in java.
Ex:
System.out.print("Input name, age, address, city: ");
user will input these details separated with space
what is expected in console:
Input name, age, address, city: Tom, 10, USA, NY
Any idea how to do this, using the Scanner class. Thanks.
Solution
Reading input from the command line with the scanner can be done by doing the following
Scanner s = new Scanner(System.in);
System.out.print("Input name, age, address, city: ");
String input = s.next();
Answered By - Jonas
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.