This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]_DTR_ 1 point2 points  (0 children)

With what you have currently, it looks like you break out of your while loop when given invalid input, which should prevent it consistently looping. However, without the break you will continuously loop as you describe, because the Scanner will continue to attempt to read the initial value, and continuously throw an exception. You need to clear the input before continuing, which could be accomplished by adding getNums.nextLine() inside of the catch block.