+ 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(
5 Antworten
+ 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
+ 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'.
+ 3
strange that I did not work, because it is working now
Thank you)