+ 1

How to use the method "Scanner" in Java ?

I've been learning the method since days. But in sololearn's coding playground, it isn't working at all. It always shows error, don't know why.

25th Jul 2020, 5:19 AM
Ankit Kashyap
Ankit Kashyap - avatar
9 Respuestas
25th Jul 2020, 5:25 AM
BroFar
BroFar - avatar
+ 4
It takes input as stream But it is very slow as compared to bufferReader Scanner both used for input and output
25th Jul 2020, 7:39 AM
Aayush $aini
Aayush $aini - avatar
+ 2
Ankit Kashyap Scanner is not a method. It's a class which contains methods like nextInt() for integer values, nextDouble() for decimal values.
25th Jul 2020, 5:35 AM
A͢J
A͢J - avatar
+ 2
Ankit Kashyap To use the Scanner class, create an object of the class and use any of the available methods found in the Scanner class and I would like to add that if we take a String input after an integer input, the String input is just skipped and moves to the next input. So to avoid this we have to again define the nextLine() function. But in BufferedReader there is no such problem.
25th Jul 2020, 5:28 PM
Smriti Kaur
Smriti Kaur - avatar
+ 2
Ankit Kashyap BufferedReader is a class that one uses to get input either directly from the user or from a file. Check out the following tutorialspoint link for more information... https://www.tutorialspoint.com/bufferedreader-class-in-java
26th Jul 2020, 7:12 AM
Smriti Kaur
Smriti Kaur - avatar
+ 1
Thanks to all... i was confused in what it actually is and in codes before.
26th Jul 2020, 6:18 AM
Ankit Kashyap
Ankit Kashyap - avatar
+ 1
Smriti Kaur thanks for the help.
27th Jul 2020, 9:51 AM
Ankit Kashyap
Ankit Kashyap - avatar
+ 1
Ankit Kashyap my pleasure...🙂
27th Jul 2020, 10:07 AM
Smriti Kaur
Smriti Kaur - avatar
0
Thanks to evryone here. But what is "Buffer reader" and how do we use. If just anyone explain it.
26th Jul 2020, 6:21 AM
Ankit Kashyap
Ankit Kashyap - avatar