Page 1 of 1

About Question enthuware.ocajp.i.v7.2.834 :

Posted: Sun Jul 28, 2013 7:57 am
by Wisevolk
I Think there's a mistake in the explanation.
Acutally this code won't compile :
public class TestClass {

public static void main(String[] args){
TestClass tc = new TestClass();
try{
tc.myMethod();
} catch (Exception e){ }
}
public void myMethod() {
yourMethod();
}

public void yourMethod() throws Exception{
throw new Exception();
}
}
It will compile if the try/catch is in myMethod and not in the main.

Re: About Question enthuware.ocajp.i.v7.2.834 :

Posted: Sun Jul 28, 2013 8:12 am
by admin
You are right but based on the point that it is trying to explain, the problem is that myMethod() is missing "throws Exception" part in its declaration. It has now been added.

thank you for your feedback.
-Paul