+ 1
Multiple inputs in a single line
How to take multiple inputs in a single line in java?
2 odpowiedzi
+ 1
If you use nextLine(), it reads entire line as one input. Remaing methods stop reading when a space encounters...
So you can input by multiple inputs by space separating by those remaining methods...
Ex: next() method for single input strings..
+ 2
enter data separated by space (default)
and read it as usual
Scanner in = new Scanner(System.in);
// enter as one line: ab cd ef
System.out.println(in.next() );
System.out.println(in.next() );
System.out.println(in.next() );