int firstNum;
while (true) {
try {
System.out.println("Enter the first number:");
firstNum = new Scanner(System.in).nextInt();
break;
} catch (InputMismatchException e) {
System.out.println("\nOnly numbers, not letters, please");
}
}