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

0

Please find error in this?

Exception in Java

10/8/2020 11:15:10 AM

Alan

3 Answers

New Answer

+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){} } }