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.

TryCatch.java 402B

12345678910111213141516171819202122232425262728293031323334
  1. package test1;
  2. public class TryCatch {
  3. int a = 0;
  4. String s = null;
  5. public void init() {
  6. s = "test";
  7. }
  8. public void doit() {
  9. a = s.length();
  10. }
  11. public void m2() {}
  12. public int m1() {
  13. m2();
  14. return a;
  15. }
  16. public int p1() {
  17. try {
  18. return s.length();
  19. }
  20. catch (NullPointerException e) {
  21. throw e;
  22. }
  23. }
  24. public int run() {
  25. return m1();
  26. }
  27. }