You are viewing a single comment's thread. Return to all comments →
public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); try { int x = sc.nextInt(), y = sc.nextInt(); System.out.println(x / y); } catch(InputMismatchException exc) { System.out.println(exc.getClass().getName()); } catch(ArithmeticException exc) { System.out.println(exc.getClass().getName() + ": " + exc.getMessage()); } finally { sc.close(); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Exception Handling (Try-catch)
You are viewing a single comment's thread. Return to all comments →