0
How to input several lines
I wrote a code with 2 inputs, one is the name of a person and the other one is the surname. When running, at the beginnin program says that the code has several inputs, and they must be separated by a line. Inputs are strigs and I tried with: Joe Johnson It does not work. How can it be done? https://code.sololearn.com/cD4tUAk5iIun/?ref=app
5 Answers
+ 4
After you've entered the first name, press enter on keyboard and enter surname on second line (same input box). This should work, but I got an error in your program.
I commented out line 9 and changed line 13 to 'surname = n.nextLine();'
You don't need line 9. You've already created a 'Scanner' in line 8.
+ 3
No problem :)
+ 1
thanks. you are righr with Scanner only one is necessary. anyway the code works in the PC. I will amend it to make it work here. thanks again
0
the code works perfetcly in the PC with Netbeans.
0
probably this app only supports one Scanner per code, and it can be used repeatedly splitting the inputs per line. thanks again!