If you are writing a switch statement that takes in a scanner type, how do you prevent a runtime error if a string or char is entered.
Scanner s = new Scanner(System.in);
int a;
a = s.nextInt();
switch(a){
}
So if i ran the code and entered "abc" then i would get an error. I would rather it just tell me that it the input was invalid and ask for the input again.