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

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
Wisevolk
Posts: 33
Joined: Thu Jul 18, 2013 6:06 pm
Contact:

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

Post 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.

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests