Reading input using Scanner causes an infinite loop in Java [duplicate]
问题 This question already has answers here : How to handle infinite loop caused by invalid input (InputMismatchException) using Scanner (5 answers) Closed 2 years ago . In my program I'm trying to get a user to input an int between 1-3 and then do something based off what they type. If it is not a number or not one of the options then it will allow them to reenter a valid option. The issue I have is I'm having trouble brainstorming how to not have it infinitely loop and just allow them to enter