+ 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.
9 Answers
+ 9
Ankit Kashyap please look at my code.
https://code.sololearn.com/cD4MMdq176hj/?ref=app
+ 4
It takes input as stream
But it is very slow as compared to bufferReader
Scanner both used for input and output
+ 2
Ankit Kashyap Scanner is not a method. It's a class which contains methods like nextInt() for integer values, nextDouble() for decimal values.
+ 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.
+ 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
+ 1
Thanks to all... i was confused in what it actually is and in codes before.
+ 1
Smriti Kaur thanks for the help.
+ 1
Ankit Kashyap my pleasure...đ
0
Thanks to evryone here.
But what is "Buffer reader" and how do we use. If just anyone explain it.