+ 25

In java

If we want to get a variable in the form of Float and lnteger and use BufferedReader functions What are the methods used?

8th Jun 2020, 12:59 PM
sasan zare
sasan zare - avatar
5 odpowiedzi
+ 16
No, I don't want an example. What methods are used? What methods are used for floats and integers in bufferereaders? Only methods?
8th Jun 2020, 5:27 PM
sasan zare
sasan zare - avatar
+ 5
Do you mean, something like that?... BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));     int i = Integer.parseInt(reader.readLine()); float f = Float.parseFloat(reader.readLine());
8th Jun 2020, 4:27 PM
Neuromonkey
Neuromonkey - avatar
+ 5
There are no methods to read integers directly. You have to convert the input..
9th Jun 2020, 4:26 AM
Neuromonkey
Neuromonkey - avatar
+ 4
API: public class BufferedReader extends Reader Reads text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines. Why do you think it can reads floats ?
8th Jun 2020, 6:40 PM
zemiak
+ 3
sasan zare You can look here: https://docs.oracle.com/javase/8/docs/api/java/io/BufferedReader.html BufferedReader has no methods for int or float. So you have to do it like in Neuromonkeys example.
8th Jun 2020, 6:36 PM
Denise Roßberg
Denise Roßberg - avatar