if scanner input is not an integer java code example Example: scanner check if int boolean isAnInt = scanner.hasNextInt();