Why its asking to enter digit only once? | Sololearn: Learn to code for FREE!


Why its asking to enter digit only once?

I put two scanner ,but here when I run code it shows once only once and shows some exception error. https://code.sololearn.com/cVXX8DGK2Qy9/?ref=app

4/23/2020 9:00:13 AM


5 Answers

New Answer


Remove line 12 Change line 15 to - num2 =digit.nextInt(); Also 🌠Ankur🌠 do not create more than one instance of scanner class, it can be avoided almost 90% of time. Just a single instance is more than enough for pretty much all the basic programs we write. Edit: It is allowed or not is secondry, I'm saying it's unnecessary. Hope you get the difference.


Sololearn doesn't allow creating 2 or more instance of Scanner object


Avinesh still same but got it ,it doesn't allow 2 or more scanner obj, and yes I got your point 🙂✌️


That's sad , anyway thanks ✌️🙂


Yes I got the difference ,thanks