guys please help me ./....


what is the meaning of scanner and what is the uses of import java.util.scanner?


need some help......

Recommended Answers

All 2 Replies

Member Avatar for ztini

java.util.Scanner allows you to access the Scanner class contained within the java.util package. This class and methods can allow you to, among other things, gather keyboard input or read a file.

For instance:

Scanner in = new Scanner(System.in);
String input = in.next();

Oracle's Scanning tutorial has more information on the topic.

The import statement is a way of telling the compiler where to look for class definitions when the class is in a package. It saves you from having to code the full package name when you use a class.
Without the import java.util.Scanner; statement, you would have to code
java.util.Scanner in = new java.util.Scanner(System.in);

For this case maybe it doesn't save much, but if you use the Scanner class many times it can save a lot of typing and make the code a little less cluttered looking.


Note: The class name is Scanner not scanner. Case is important

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.