0
Please find error in this?
Exception in Java
3 Antworten
+ 8
Alan
It's not an exception..
readLine() method in DataInputStream is deprecated.
Deprecated class or method means it is no longer important and you should not use it.
You can either use Scanner class or readLine() of BufferedReader class.
Here is more info 👇
https://stackoverflow.com/questions/5611387/datainputstream-deprecated-readline-method
0
https://code.sololearn.com/cK9a8840oMU2/?ref=app
0
import java.io.*;
public class TryText
{
public static void main(String[] args)//throws Exception
{
DataInputStream in = new DataInputStream(System.in);
int a=0,b=0,c=0, x=0,y=0;
try
{
System.out.println("Enter the first number");
a=Integer.parseInt(in.readLine());
System.out.println("Enter the second number");
b=Integer.parseInt(in.readLine());
System.out.println("Enter the third number");
c=Integer.parseInt(in.readLine());
try
{
x=a/(b-c); //may throw exception
}
//handling the exception
catch(ArithmeticException e)
{
System.out.println("Division by zero");
}
y=a/(b+c);
System.out.println("Y= "+y);
}
catch(Exception e){}
}
}