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
2 Answers
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
0
int accept() {
while (! sc.hasNextInt() ) {
sc.next();
}
return sc.nextInt();
}