Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1.  
  2. public class ExeptionUse {
  3. private static int pa;
  4. private static int pb;
  5.  
  6.  
  7. public ExeptionUse(int a, int b) {
  8. // TODO Auto-generated constructor stub
  9. this.pa = a;
  10. this.pb = b;
  11. }
  12.  
  13. public ExeptionUse(){
  14. // TODO Auto-generated constructor stub
  15. this.pa = 0;
  16. this.pb = 0;
  17. }
  18.  
  19. private static int Divide(int a, int b) {
  20. return a/b;
  21. }
  22.  
  23. public static void exeption(int a, int b) {
  24. int result = 0;
  25. try {
  26. result = Divide(a,b);
  27. }catch (ArithmeticException e) {
  28. throw new MyExeption("\n\tDivision by 0!!");
  29. }finally{
  30. System.out.printf("Result is: %d",result);
  31. }
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement