Please find error in this? | Sololearn: Learn to code for FREE!


Please find error in this?

Exception in Java

10/8/2020 11:15:10 AM


3 Answers

New Answer


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 👇



import*; public class TryText { public static void main(String[] args)//throws Exception { DataInputStream in = new DataInputStream(; 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){} } }