0

Help me with this

Basically i wanted to write a programme that would run until the user makes no wrong input. So i came up with this but its has StackError . Help me . Code is written here https://code.sololearn.com/cYIt4nFZ931m/?ref=app

22nd Mar 2021, 7:03 AM
Suryansh sharma
Suryansh sharma - avatar
2 Réponses
0
thats because scanner will read the same input everytime, and reach the limit of the memory u use in stack,thus throwing that exception
22nd Mar 2021, 7:54 AM
durian
durian - avatar
0
int accept() { while (! sc.hasNextInt() ) { sc.next(); } return sc.nextInt(); }
22nd Mar 2021, 8:21 PM
zemiak