We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importjava.io.*;importjava.util.*;publicclassSolution{publicstaticvoidmain(String[]args){Scannerscan=newScanner(System.in);Stringx1=scan.nextLine();Stringy1=scan.nextLine();try{intx=Integer.parseInt(x1);inty=Integer.parseInt(y1);if(x==0||y==0){System.out.println("java.lang.ArithmeticException: / by zero");}else{System.out.println(x/y);}}catch(Exceptionex){System.out.println("java.util.InputMismatchException");}}}
Java Exception Handling (Try-catch)
You are viewing a single comment's thread. Return to all comments →