int i = 0;try{ i = Integer.parseInt(s.nextLine());}catch (Exception ex){ System.out.println("That was not a number.");}