scanner validate int onlt java code example Example: scanner check if int boolean isAnInt = scanner.hasNextInt();