enthuware.ocajp.i.v7.2.1276:
Code: Select all
public class TestClass{
public static void main(String[] args){
TestClass tc = new TestClass();
try{
tc.m1();
}
catch (MyException e){
tc.m1();
}
finally{
tc.m2();
}
}
public void m1() throws MyException{
throw new MyException();
}
public void m2() throws RuntimeException{
throw new NullPointerException();
}
}
Code: Select all
class NewException extends Exception {}
class AnotherException extends Exception {}
public class ExceptionTest{
public static void main(String [] args) throws Exception{
try{
m2();
}
finally{ m3(); }
}
public static void m2() throws NewException{ throw new NewException(); }
public static void m3() throws AnotherException{ throw new AnotherException(); }
}
in enthuware.ocajp.i.v7.2.1276, the catch clause is using a method which is throwing a checked exception.
in enthuware.ocajp.i.v7.2.1006 the finally clause is using a method which is throwing a checked exception.
in enthuware.ocajp.i.v7.2.1276, we said: "It will not compile because of unhandled exception", so if the catch clause is using a method which is throwing a checked exception, this exception should be handled.
Why is it that we don't need to handle the checked exception thrown by the finally clause in enthuware.ocajp.i.v7.2.1006??