You are viewing a single comment's thread. Return to all comments →
perfect solution in java for passing all the test cases :
public static void main(String[] args) { try{ Scanner s = new Scanner(System.in); System.out.println(s.nextInt()/s.nextInt()); }catch(ArithmeticException e) { System.out.println(e);
}catch(InputMismatchException e) { System.out.println(e.getClass().getName()); } catch(Exception e) { System.out.println(e.getClass()); } }
Java Exception Handling (Try-catch)
You are viewing a single comment's thread. Return to all comments →
perfect solution in java for passing all the test cases :
public static void main(String[] args) { try{ Scanner s = new Scanner(System.in); System.out.println(s.nextInt()/s.nextInt()); }catch(ArithmeticException e) { System.out.println(e);