+ 3

How can I implement sequential input?

I have a code int a = new Scanner(System.in).nextInt(); int b = new Scanner(System.in).nextInt(); but the compiler does not see the second input(

12th Jun 2018, 6:53 PM
Вертолет И Автобус
Вертолет И Автобус - avatar
3 Réponses
+ 4
Miu-miu HASKEER if by sequential you mean an infinite amount of lines as input, do it like this: https://code.sololearn.com/c9tJUsrhx1VC/?ref=app
12th Jun 2018, 8:03 PM
Andre Daniel
Andre Daniel - avatar
+ 3
Create a single scanner, multiple that use the same stream at the same time will cause problems. Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); Then input it like so on code playground: 10 20 a will receive the value '10'. b will receive the value "20'.
12th Jun 2018, 6:54 PM
Rrestoring faith
Rrestoring faith - avatar
+ 3
strange that I did not work, because it is working now Thank you)
12th Jun 2018, 7:07 PM
Вертолет И Автобус
Вертолет И Автобус - avatar