Java Exception Handling (Try-catch)

  • + 0 comments

    May be because you are using older version of java. In java 8 this code passes all the testcases successfully.

    try
            {
                int a=obj.nextInt();
                int b=obj.nextInt();
                System.out.print(a/b);
            }
            catch(InputMismatchException e)
            {
                System.out.print(e.getClass().getName());
            }
            catch(Exception e)
            {
                System.out.print(e);
            }