Is there a method that allows me to check if the user entered anything other than an integer. For example I want the user only to enter an integer, I have this code.
try { integerVariable = sc.nextInt(); } catch(InputMismatchException e) { System.err.println("try again, wrong type"); } }
That is only good for one time. How would I go about doing this in a loop say 5 times or something?