Exception Handling

  1. import java.io.*;
  2. class exhand
  3.  
  4. {
  5.  
  6. public static void main(String args[])
  7. {
  8. try
  9. {
  10. System.out.println("Before division");
  11. int i = Integer.parseInt(args[0]);
  12. int j = Integer.parseInt(args[1]);
  13. System.out.println("Afer Division");
  14. System.out.println(i/j);
  15. }
  16. catch(ArithmeticException e)
  17. {
  18. System.out.println("Error in denomination");
  19. }
  20. catch(ArrayIndexOutOfBoundsException ae)
  21. {
  22. System.out.println("Array range out of range");
  23. }
  24. catch(NumberFormatException ze)
  25. {
  26. System.out.println("Data type Error");
  27. }
  28. finally
  29. {
  30. System.out.println("final block arrived");
  31. }
  32.  
  33. }
  34. }
  35.