You are viewing a single comment's thread. Return to all comments →
Thanks. I didn't know I can pass objects to try block.
4th test case got failed tho, so I fixed it a lil bit.
public static void main(String[] args) { try(Scanner in = new Scanner(System.in)) { System.out.println(in.nextInt()/in.nextInt()); } catch(InputMismatchException ex) { System.out.println(ex.getClass().getName()); } catch(ArithmeticException ae) { System.out.println(ae); } }
Java Exception Handling (Try-catch)
You are viewing a single comment's thread. Return to all comments →
Thanks. I didn't know I can pass objects to try block.
4th test case got failed tho, so I fixed it a lil bit.