It tells the compiler, that any time you use a Scanner, you mean the one which is located in java.util

Answer from Georg Plaz on Stack Overflow
🌐
W3Schools
w3schools.com › java › java_user_input.asp
Java User Input (Scanner class)
The Scanner class is used to get user input, and it is found in the java.util package.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › Java-Scanner-import
Java Scanner import
When you add an import statement ... import statement at the top of many Java classes means that somewhere in the code, the Scanner class is being used....
Published: February 12, 2026
Discussions

import java.util.Scanner;
You will understand with time, in java everything is a class and you are creating an instance of the scanner class and passing System.in as the parameter to its constructor. For now just know when you want the user to input something this is how you do. More on reddit.com
🌐 r/learnprogramming
21
23
December 14, 2025
confused about this!
Scanner is a class in java that is used for a lot of user input type stuff. So essentially what you are doing is creating a Scanner to grab the user input(the system.in part). Next you call the function reader.nextLine() which obtains whatever the user inputs, and then assign that value to a string variable called name. then you just print the name out edit: it is important to note that scanners are used a lot for file input and output stuff More on reddit.com
🌐 r/learnjava
16
2
December 12, 2017
People also ask

Q1. What is the Scanner class in Java?
The Scanner class is a utility in Java that helps programs read input from the user, files, or strings.
🌐
intellipaat.com
intellipaat.com › home › blog › scanner class in java
Scanner Class in Java: Syntax, Methods, and Examples
Q3. How to write a Scanner class?
You create a Scanner object in your program using: Scanner sc = new Scanner(System.in);
🌐
intellipaat.com
intellipaat.com › home › blog › scanner class in java
Scanner Class in Java: Syntax, Methods, and Examples
Q2. What type of class is the Scanner class?
Scanner is a built-in class in java.util package.
🌐
intellipaat.com
intellipaat.com › home › blog › scanner class in java
Scanner Class in Java: Syntax, Methods, and Examples
🌐
Educative
educative.io › answers › what-is-javautilscanner-in-java
What is java.util.Scanner in Java?
Scanner is a class available in the java.util package. It is used to take input from a user for any primitive datatype (int, float, string, and so on). Before using the Scanner class, we need to import it.
🌐
Zero To Mastery
zerotomastery.io › blog › java-scanner
Beginner's Guide To Java Scanner (With Code Examples) | Zero To Mastery
Such a rookie move but we all fall for it at some point. If you remember from earlier, Scanner is part of the java.util package, which means it isn’t automatically available. So if you forget to import it, your program won’t compile, and you’ll see this error:
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › java › util › java_util_scanner.htm
Scanner Class in Java
The scanner class can be used by following the steps below − · The first and important step is to import the java.util.Scanner at the top of our code, as without the Scanner class, we cannot use its methods.
🌐
LabEx
labex.io › questions › what-is-the-purpose-of-import-java-util-scanner-line-261413
What is the purpose of 'import java.util.Scanner;' line? | LabEx
October 2, 2025 - The line import java.util.Scanner; is used to include the Scanner class from the java.util package in your Java program.
🌐
GeeksforGeeks
geeksforgeeks.org › java › scanner-class-in-java
Scanner Class in Java - GeeksforGeeks
The Scanner class makes input handling simple and user-friendly in Java programs. Used to read user input from keyboard. Supports different data types like int, double, String, etc.
Published: May 27, 2026
🌐
JavaBeat
javabeat.net › import-scanner-class-java
How to Import a Scanner Class in Java?
January 31, 2024 - Importing the Scanner class in Java is a common practice for reading the input from various sources. The Scanner class divides the input into tokens and the scanner object reads each token using different methods. To import the Java Scanner class, use “import java.util.Scanner;”, “import ...
🌐
javaspring
javaspring.net › blog › import-java-scanner
Mastering `import java.util.Scanner`: A Comprehensive Guide — javaspring.net
By writing import java.util.Scanner; at the top of your Java file, you are telling the Java compiler that you want to use the Scanner class from the java.util package.
🌐
Programiz
programiz.com › java-programming › scanner
Java Scanner Class | Programiz
March 13, 2024 - The Scanner class of the java.util package is used to read input data from different sources like input streams, users, files, etc. In this tutorial, we will learn about the Java Scanner and its methods with the help of examples.
🌐
Stack Overflow
stackoverflow.com › questions › 69239950 › module-question-java-import-java-util-scanner
Module Question Java import java.util.Scanner; - Stack Overflow
Share · Improve this answer · ... Think what it means ( import java.util.Scanner ) It means you want to use a scanner class which is available in java.util package....
🌐
Reddit
reddit.com › r/learnjava › confused about this!
r/learnjava on Reddit: confused about this!
December 12, 2017 -

from http://mooc.cs.helsinki.fi/programming-part1/material-2013/week-1?noredirect=1

I'm confused about what scanner system does. so first

  1. "import java.util.Scanner to" import the scanner system into the main body program.

  2. Scanner reader = new Scanner(System.in) set scanner name as reader and creates new scanner that will parse the (system.in).

ugh I'm really confused here, they didn't really explain what each words mean, how they translate over to the next and such. I tried googling but kind of get it but no at the same time.

import java.util.Scanner;

public class Greeting {

public static void main(String[] args) {

    Scanner reader = new Scanner(System.in);

    System.out.print("Who is greeted: ");
    String name = reader.nextLine(); // Reads a line of input from the user and assigns it
                                     //     to the variable called name

    System.out.print("Hi " + name);
}

}

Top answer
1 of 2
2
Scanner is a class in java that is used for a lot of user input type stuff. So essentially what you are doing is creating a Scanner to grab the user input(the system.in part). Next you call the function reader.nextLine() which obtains whatever the user inputs, and then assign that value to a string variable called name. then you just print the name out edit: it is important to note that scanners are used a lot for file input and output stuff
2 of 2
2
If you're just getting started, it might be better to just accept some of this stuff as boilerplate, and ignore it for the time being. It will start making sense and become easier to understand once you learn more, and start writing your own classes and things like that. But I'll try to explain some of it. System.in is the standard input stream. (This uses the in variable from the System class). Typically when you run your program and type stuff in to the console, that input gets directed to this input stream. In your program, you can read from this input stream to get the user's input. By itself, the input stream can only give you raw bytes, which is typically not useful, so you'll need to use something to convert the bytes to something intelligible, which leads to... Scanner is a class that can take raw inputs of bytes or characters, and can parse that input into lines, words, numbers, and so forth. In your case, you're creating a Scanner that gets its input from the standard input stream. In java, classes are organized into packages. In the java standard library, there are many packages, and each package has many classes within in. Because there are so many classes, you need to say exactly which class you want to use. You do this using an import statement. In the case of the Scanner class, it is located in the java.util package, so you need to import java.util.Scanner; and that will let you use the Scanner class in your class, and java will know exactly which class you intend to use. The java.lang package is kind of a special package. You can use classes in that package (such as the System class) without needing an import statement. They are imported automatically.
🌐
Medium
medium.com › @farhan77070 › understanding-the-java-scanner-class-a-complete-guide-3cd33f41dcae
Understanding the Java Scanner Class: A Complete Guide | by Md Farhan Alam | Medium
January 25, 2025 - The Scanner class is part of the java.util package and allows us to capture input from various sources, such as user input from the keyboard, files, or streams. It breaks the input into tokens using delimiters (whitespace by default), and those ...
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › Scanner.html
Scanner (Java Platform SE 8 )
July 21, 2026 - Java™ Platform Standard Ed. 8 ... A simple text scanner which can parse primitive types and strings using regular expressions.
🌐
Augustana University
lovelace.augustana.edu › q2a › index.php › 854 › what-the-difference-between-java-util-and-java-util-scanner
What is the difference between java.util.* and java.util.Scanner? - Augustana CSC Q&A
January 21, 2019 - I don't know what you mean by java.util.Scanner but there are 2 java imports we use: 1. import java.awt. > to use Graphic 2. import java.util. > to use Scanner · java.util is a package which contains many classes. One of those classes is Scanner
🌐
SoftTeco
softteco.com › home › java development › java scanner
Java Scanner: everything you need to know about this Java clas
June 9, 2026 - Since Scanner belongs to the java.util package, you can import it without downloading any external libraries.
🌐
Intellipaat
intellipaat.com › home › blog › scanner class in java
Scanner Class in Java: Syntax, Methods, and Examples
September 8, 2026 - The Scanner class in Java is a utility class used to read input from the keyboard (System.in), files, strings, and other input streams.