🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #97

missing return statement

#97
From: Kang
Date: Wed, 04 May 2005 02:12
30 lines
1689 bytes
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();
    }
}
Technical Details
Message-ID: <42782ee5$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newshub.sdsu.edu!elnk-nf2-pas!elnk-pas-nf1!newsfeed.earthlink.net!pd7cy1no!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 1089d0,36777f101f4060bd,start
X-Google-Attributes: gid1089d0,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Kang" <kang@hao.com>
Newsgroups: borland.public.jbuilder.java.api
Subject: missing return statement
Date: Wed, 4 May 2005 11:12:00 +0900
Lines: 32
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478
NNTP-Posting-Host: 152.99.193.27
Message-ID: <42782ee5$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1115172581 152.99.193.27 (3 May 2005 19:09:41 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newshub.sdsu.edu!elnk-nf2-pas!elnk-pas-nf1!newsfeed.earthlink.net!pd7cy1no!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail