+ 2
What is bufferReader? Give some details about it n usefulness about it...
plzzz give one example to explain d whole thing
6 Antworten
+ 3
Buffered Reader is just like Scanner...
BUT, Buffered Reader throws exceptions which makes it unworthy. Whenever we declare Buffered Reader, we also have to declare a statement for IOException.
Thus, we prefer Scanned over Buffered Reader.
For example,
import java.io.*;
public class CalcArea
{
public static void main ( String args[] ) throws IOException
{
System.out.print ( "Enter the radius: " );
BufferedReader input = new BufferedReader ( new InputStreamReader ( System.in ) );
String inputString = input.readLine();
double radius = Double.parseDouble ( inputString );
double area = 3.14159 * radius * radius;
System.out.println ( "Area is: " + area );
}
}
Hope it helped...
If liked plz follow me😅😉
+ 1
Martin Taylor I like your way to go direct to point 😁
0
Can u explain me this line ? why u used this line n what dis need in d program? Mayank Rampuriya can we used in single line n yes so how?
String inputString= input.readline();
0
Mayank Rampuriya... Stringing inputstring=input.readLine() basically reads the keys from the keyboard as a buffer....double radius=Double.parseDouble(inputString) converts what u entered from the keyboard to double data type...then the double data can be used in ur program....this is the basic explanation...that u can understand from above....readLine() is a function of BufferedReader class...