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
🌐
Quora
quora.com › What-does-import-java-util-Scanner-mean-in-Java
What does import java.util.Scanner mean in Java? - Quora
Answer (1 of 20): Javas Scanner is a fun tool used to get user input. The way I will be doing it is via the console, but it can be done by other means of input, such as text files. Once it is called, the user can type anything to the console, type their input, and hit enter.
🌐
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....
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
[JAVA]Why do we have to import classes like Random and Scanner? Why not just have it built into the language?
EDIT: Based on other responses below, let me clarify how I'm responding. I'm assuming OP genuinely is asking why the classes cannot be built in. You certainly could do an implicit import of the necessary classes instead of building them into the language itself. I raise three issues in my post, but with an implicit import, only the first issue remains. The responses here about memory are absolutely not correct. Why not just have all of these classes already built in the language It adds complexity to the language for no gains. The only advantage you get is nominal: not having to type import. However, you pay a huge price. First, you introduce a large number of reserved keywords into the language. Let's say you create a new PRNG. What do you call the class? Random? No, you can't do that, because the name is already in use. So everyone has to be aware of all the different class names that are built in. And how many classes are we talking about here? Are all the class names even unique? Can you even state that across the Java platform, there are no class names that are the same? Second, you create implementation complexity. When you state that Scanner is actually a part of the language, it has to implemented as a new grammar rule. Lexing and parsing and optimization now need to take this name into account, for no benefit, because like I said, these classes don't actually have any unique grammar behind them. You do not want exploding complexity to implement and maintain in your compilers. Third, you create language inflexibility. You can't create a lean version and implementation of the Java platform, because to implement the language, you have to implement all those classes. They are built into the language itself, after all. More on reddit.com
🌐 r/learnprogramming
34
47
July 19, 2014
my until.java.Scanner; doesn't work
so it says "the import java.util.Scanner is never used" Idk what to do please help I'm new More on reddit.com
🌐 r/javahelp
5
0
August 30, 2022
🌐
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. To use the Scanner class, create an object of the class and use any of the available methods found in the Scanner class documentation.
🌐
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
Find elsewhere
🌐
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.
🌐
JavaBeat
javabeat.net › home › how to import a scanner class in java?
How to Import a Scanner Class in Java?
January 31, 2024 - Cleaner Code: The “import java.util.Scanner;” provides cleaner code than using the fully qualified name convention. To read input in Java, BufferedReader, and Console classes are also used.
🌐
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.
🌐
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
🌐
Programiz
programiz.com › java-programming › scanner
Java Scanner (With Examples)
The Scanner class of the java.util package is used to read input data from different sources like input streams, files, etc. Let's take an example. import java.util.Scanner; class Main { public static void main(String[] args) { // creates an object of Scanner Scanner input = new Scanner(System.in); ...
🌐
javaspring
javaspring.net › blog › import-java-scanner
Mastering `import java.util.Scanner`: A Comprehensive Guide — javaspring.net
To use a class from a package other ... 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....
🌐
TutorialsPoint
tutorialspoint.com › java › util › java_util_scanner.htm
Scanner Class in Java
The Scanner class plays an important role in Java by providing user-based input. The Scanner class is a part of java.util package, and a scanner can read text from any object that implements the Readable interface.
🌐
Oracle
docs.oracle.com › javase › tutorial › › essential › io › scanning.html
Scanning (The Java™ Tutorials > Essential Java Classes > Basic I/O)
By default, a scanner uses white space to separate tokens. (White space characters include blanks, tabs, and line terminators. For the full list, refer to the documentation for Character.isWhitespace.) To see how scanning works, let's look at ScanXan, a program that reads the individual words in xanadu.txt and prints them out, one per line. import java.io.*; import java.util.Scanner; public class ScanXan { public static void main(String[] args) throws IOException { Scanner s = null; try { s = new Scanner(new BufferedReader(new FileReader("xanadu.txt"))); while (s.hasNext()) { System.out.println(s.next()); } } finally { if (s != null) { s.close(); } } } } Notice that ScanXan invokes Scanner's close method when it is done with the scanner object.
🌐
Note
note.com › トップ › コンピュータ・it › プログラミング › 【java】scannerの基本的な使い方
[Java] Basic Usage of Scanner|コード日和(びより)♪プログラミング講師
March 28, 2025 - Scanner is a way to receive input from the keyboard in a program. Using this, you can retrieve characters and numbers entered by the user in a Java program. import java.util.Scanner; // Scannerを使うための準備 public class Main { public ...
🌐
LabEx
labex.io › tutorials › java-how-to-import-scanner-in-java-419202
How to import Scanner in Java | LabEx
In Java programming, the Scanner class is a powerful utility located in the java.util package that provides a simple way to read input from various sources. It serves as a fundamental tool for parsing primitive types and strings using regular ...
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java scanner class tutorial with examples
Java Scanner Class Tutorial With Examples
April 1, 2025 - Once the Scanner class is imported into the Java program, you can use it to read the input of various data types. Depending on whether you want to read the input from standard input or file or channel, you can pass the appropriate predefined ...
🌐
Coderanch
coderanch.com › t › 685766 › java › difference-import-java-util-import
what is the difference between import java.util.* and import java.util.Scanner; [Solved] (Beginning Java forum at Coderanch)
October 13, 2017 - I am trying to read double numbers from a file named data.txt , then to sum them up and print the result to the standard output; the below code won't compile and dosn't seem to import the Scanner class but this one below works and prints the result ... the below code won't compile What does this mean? What exactly happens when you try to compile? Both codes compile fine for me. While there is a difference between the two import statements (namely in how other classes in the java.util package are treated), it doesn't make a difference to this particular code (because it uses no other classes from java.util).
🌐
Quora
quora.com › What-is-the-exact-meaning-of-import-Java-util-Scanner-in-Java
What is the exact meaning of import Java.util.Scanner in Java? - Quora
Answer (1 of 4): > import java.util.Scanner; I'll go step by step. First of all to understand this, you need to know what a package is? In java, packages are the container for classes and whenever we want to use the features of another classes that are defined in another package,we use import ke...