- What is a Scanner in Java? Scanner is a class in "Java. util" package that is used to read input. (System.in) → user input Different data types: nextInt()
Common Methods in Scanner
nextInt() → reads integer
nextDouble() → reads decimal numbers
nextLine() → reads a full line of text
next() → reads single word
hasNextInt(), hasNextLine() → check before reading
Top comments (0)