+ 1
where i can use scanner in java..what are the rules
explain scanner and where we use it and why
9 Answers
+ 3
u can use the Scanner class for getting input and reading the files.
for this u need to create a Scanner object
Scanner sc= new Scanner();
int input= sc.nextInt();
+ 3
Scanner class and buffered class are made by get inputs . If you want take small amount of user input you use Scanner class otherwise you use Buffer class inputs. before you use scanner class you need import util first.. like import java.util.*; And then use Scanner sc = new Scanner(System.in);
+ 1
yes scanner is used to get input from user..
+ 1
Scanner is a class under java.util package and it can be used for taking input from user of any kind of data type except char by creating an instance variable of Scanner class
eg:
Scanner sc=new Scanner(System.in);
int var=sc.nextInt (); //for integer
float var=sc.nextFloat (); // for float
String var=sc.next();// for string of one word
String var=sc.nextLine();// for strings
0
I think scanner is used for to get input from the user..
0
Scanner is like DataInputStream. We use them to write prompts like "Enter a no." or "Enter your name" from user.
0
Scanner is a class by using this we get the only integer data
we need to create a instance variable for accessing a Scanner class methods
ex:: Scanner in=new Scanner (System.in);
int var=in.nextInt();
0
scanner is used for getting input from user.
0
before you use it u have to import the util package and then u can use it in main method