You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GetThrowables.java 703B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package test1;
  2. class GetThrow1 extends Exception {
  3. /** default serialVersionUID */
  4. private static final long serialVersionUID = 1L;
  5. }
  6. class GetThrow2 extends Exception {
  7. /** default serialVersionUID */
  8. private static final long serialVersionUID = 1L;
  9. }
  10. public class GetThrowables {
  11. int k = 0;
  12. public void m1() throws GetThrow1, GetThrow2 {
  13. if (k < 0)
  14. throw new GetThrow1();
  15. else if (k == 1)
  16. throw new GetThrow2();
  17. k = 1;
  18. }
  19. public int run() throws GetThrow2 {
  20. int i = 0;
  21. try {
  22. try {
  23. m1();
  24. }
  25. catch (GetThrow1 e) {
  26. i = 1;
  27. throw e;
  28. }
  29. finally {
  30. i += 3;
  31. }
  32. }
  33. catch (GetThrow1 e2) {
  34. ++i;
  35. }
  36. return i;
  37. }
  38. }