I need help in java with Scanner Class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I need help in java with Scanner Class

I'm solving the "New Driver's License" challenge and I typed the code on Netbeans and I didn't get any error, but when I typed it on SOLOLEARN I got errors even though I made the same entry in the challenge This is the code link: https://code.sololearn.com/cF29I4P4UBSx

13th Sep 2021, 9:35 PM
Saoula Hocine
Saoula Hocine - avatar
1 Answer
+ 3
Your Scanners are interfering with each other, because they use the same input stream. Elevate one of the Scanner objects to a class member so it can be used in both methods of the class and make it static. Delete the second Scanner object and change whichever lines you need so that the deleted Scanner object is changed to the one you kept. Then your code seems to work fine. https://code.sololearn.com/cfPZRhgN9vjK/?ref=app
13th Sep 2021, 11:16 PM
ChaoticDawg
ChaoticDawg - avatar