+ 1

Weird error?

Can somebody please help explain what this error is I'm getting? I'm not sure if I put something wrong with the javas scanner. I didnt think so, but idk why this wont run and just show what username you input. You have to put continue to proceed, then enter a username. It should print the username you typed back out to you. https://code.sololearn.com/cxWjSJEoJx8N/?ref=app https://code.sololearn.com/cxWjSJEoJx8N/?ref=app

24th Mar 2020, 8:51 AM
Dustin James Locey
Dustin James Locey - avatar
2 Réponses
+ 1
Make Scanner object class level. Then you can Use it in both functions through single object. No need to create two objects infact not allowed per class.
24th Mar 2020, 9:29 AM
Jayakrishna 🇮🇳
0
Instead of making two scanner it's better to create static object if it's not really need to encapsulate it. You can replace the scanner in method to something like this static Scanner = new Scanner(System.in);
24th Mar 2020, 2:22 PM
Odiesta Shandikarona
Odiesta Shandikarona - avatar