+ 1

where i can use scanner in java..what are the rules

explain scanner and where we use it and why

22nd Jun 2016, 9:02 PM
Kriti Kaur
Kriti Kaur - avatar
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();
23rd Jun 2016, 10:21 AM
Saud Ahmad
Saud Ahmad - avatar
+ 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);
7th Jul 2016, 6:20 PM
Bhavesh
Bhavesh - avatar
+ 1
yes scanner is used to get input from user..
23rd Jun 2016, 10:25 AM
sonali kaur
+ 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
30th Jun 2016, 5:48 AM
VISHAL KUMAR
0
I think scanner is used for to get input from the user..
23rd Jun 2016, 6:40 AM
Sarath Maya
Sarath Maya - avatar
0
Scanner is like DataInputStream. We use them to write prompts like "Enter a no." or "Enter your name" from user.
23rd Jun 2016, 4:21 PM
Roshan Rijal
Roshan Rijal - avatar
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();
24th Jun 2016, 5:18 PM
chandra kanth
0
scanner is used for getting input from user.
30th Jun 2016, 10:33 AM
Aishwarya Patil
Aishwarya Patil - avatar
0
before you use it u have to import the util package and then u can use it in main method
9th Jul 2016, 9:54 AM
sai krishna
sai krishna - avatar