It tells the compiler, that any time you use a Scanner, you mean the one which is located in java.util
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): Java’s 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.
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
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
[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
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
Videos
05:41
How to import the Java Scanner - YouTube
02:24
Java | Import Package in Java | Import java.util.scanner | Coder ...
User input in Java is easy! ⌨️
Java User Input (Scanner class) | Java Tutorial for Beginners ...
How to accept user input in Java ⌨️【8 minutes】
13:26
Understanding java.util.Scanner - YouTube
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.
Reddit
reddit.com › r/learnprogramming › import java.util.scanner;
r/learnprogramming on Reddit: import java.util.Scanner;
December 14, 2025 -
I recently started learning Java and I'm having trouble understanding how this code works -
import java.util.Scanner;
class Program {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Input a number: ");
int num = in.nextInt();
System.out.printf("Your number: %d \n", num);
in.close();
}
}
Why do I need to know this? Top answer 1 of 5
22
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.
2 of 5
7
It's a simple example of a program that takes in user input and displays it as output. I would expect whatever tutorial or curriculum you're following to go on to extend it to do more things. Most tutorials will start with command line programs like this, and knowing how to get user input is pretty important. Is there something specific about it you're struggling to understand?
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
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
"import java.util.Scanner to" import the scanner system into the main body program.
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.
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); ...
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.
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...