0

guys please help me ./....


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


need some help......

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by NormR1
0

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.

-1

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

Edited by NormR1: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.