0
Why the scanner object not accepting the string input from stdin ?
I've used scanner object for accepting 2 inputs First int input =4 and second string input ="ground fun" I don't want to close the scanner object and then create a new scanner object for string input Expected output should be 8 Playground fun https://code.sololearn.com/c0hlmzoAUjYP/?ref=app
2 Antworten
0
It's something about the buffer. Put this between line 12 and 13:
sc.nextLine()
0
nextInt() doesn't read end_of_line after number,
so nextLine() reads end_of_line
and not expected second input
in input:
4
ground fun