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