Why its asking to enter digit only once? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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

23rd Apr 2020, 9:00 AM
🌠Ankur🌠
🌠Ankur🌠 - avatar
4 Answers
+ 1
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.
23rd Apr 2020, 9:06 AM
Avinesh
Avinesh - avatar
+ 1
Avinesh still same but got it ,it doesn't allow 2 or more scanner obj, and yes I got your point 🙂✌️
23rd Apr 2020, 9:11 AM
🌠Ankur🌠
🌠Ankur🌠 - avatar
0
That's sad , anyway thanks ✌️🙂
23rd Apr 2020, 9:07 AM
🌠Ankur🌠
🌠Ankur🌠 - avatar
0
Yes I got the difference ,thanks
23rd Apr 2020, 9:16 AM
🌠Ankur🌠
🌠Ankur🌠 - avatar