Normally I do my code along the lines of this for validation:
public static void Menu()
{
Scanner keyboard = new Scanner(System.in);
if (!keyboard.hasNextInt())
{
System.out.println("Incorrect input, try again");
Menu();
}
else
{
// switch statement etc
}
}
I am just wondering is this bad practice? And if so why and what are better ways of doing it besides using recursion. I have used recursion for getting the power of numbers and some other things so I understand the idea of it.