+ 1

How can I send an error in Java when a user through the Scanner enters a non-numeric symbol in a variable of type int?

please help me, this to avoid an error that closes the program because of the user and thus only have have to repeat a loop (is my homework).

23rd Jul 2019, 3:34 AM
Yahir Maldonado
Yahir Maldonado - avatar
2 Answers
+ 2
You could use try/catch blocks to execute code that will print an error if the user does not type a valid integer in the Scanner. It will not stop the program's execution https://code.sololearn.com/cMWiXVT9j85Z/?ref=app
26th Jul 2019, 6:44 AM
androidCoder255
androidCoder255 - avatar
+ 1
Thank you
26th Jul 2019, 4:25 PM
Yahir Maldonado
Yahir Maldonado - avatar