BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

missing return statement

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder JavaAPI
View previous topic :: View next topic  
Author Message
Kang
Guest





PostPosted: Wed May 04, 2005 2:12 am    Post subject: missing return statement Reply with quote



I think the method1 and the method2 is the same.
Why the compiler complains "missing return statement" in the method2?
Thanks.

public class ExceptionHandlingTest {
public static void main(String[] args) throws Exception {
System.out.println(method1());
}
public static String method1() throws Exception{
try{
return "method1";
}catch(Exception e){
throw new Exception();
}finally{

}
}
public static String method2() throws Exception{
try{
return "method2";
}catch(Exception e){
method3();
}finally{

}
}
public static void method3() throws Exception{
throw new Exception();
}
}


Back to top
Kevin Dean [TeamB]
Guest





PostPosted: Wed May 04, 2005 2:59 am    Post subject: Re: missing return statement Reply with quote



Kang wrote:

Quote:
I think the method1 and the method2 is the same.
Why the compiler complains "missing return statement" in the method2?
Thanks.

In order for the compiler to prove definitively that the two are
equivalent, it would have to inline method3, and inline any methods it
calls, and so on, and so on. All the compiler sees when its compiling
method2 is a call to method3; it doesn't know or care at that point
exactly what method3 does.

--
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
http://www.datadevelopment.com/

NEW WHITEPAPERS
Team Development with JBuilder and Borland Enterprise Server
Securing Borland Enterprise Server
http://www.datadevelopment.com/papers/index.html

Please see Borland's newsgroup guidelines at
http://info.borland.com/newsgroups/guide.html

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder JavaAPI All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.