Hello
Firstly you have named your class BufferedReader, and you are doing a new BufferedReader. So, java is not looking in the BufferedReader default Library but for the constructor in your class. You have to rename the class. Taking about this part of the code.
Code:
public class BufferedReader
{
public static void main (String[]args)
{
BufferedReader dtln = new BufferedReader (new InputStreamReader(System.in));
String no;
try
{
no = dtln.readLine();
int nober1 = Integer.parseInt(no);
no = dtln.readLine();
int nober2 = integer.parseInt(no);
}
The second mistake is that you have defined two integers within a try statement and you are attempting to use them outside the try statement. Due to the scoping laws this can not be possible. So, please change that.
Code:
try
{
no = dtln.readLine();
int nober1 = Integer.parseInt(no);
no = dtln.readLine();
int nober2 = integer.parseInt(no);
}
catch (IOException e)
{
System.out.println("Error!");
}
int sum = nober1 + nober2;
System.out.println("The Sum is " +sum);
If you have any more queries do post back.
Bookmarks