01. class BadObjectException extends Exception {}
02. class BadIndexException extends IndexOutOfBoundsException {}
03.
04. public class Test {
05.
06. public void doSomething() {}
07.
08. public void aMethod() {
09. try {
10. doSomething();
11. }catch(BadIndexException be) {
12. System.out.println("BadIndexException");
13. throw new BadIndexException(){};
14. }
15. }
16.
17. public void anotherMethod() throws BadObjectException{
18. try {
19. doSomething();
20. }catch(BadObjectException be) {
21. System.out.println("BadObjectException");
22. }
23. }
24.
25. public static void main(String[] args) throws BadObjectException{
26. Test t = new Test();
27. t.aMethod();
28. t.anotherMethod();
29. }
30. }
the output is that metnod anotherMethod() would not compile.