Article View: borland.public.jbuilder.java.language
Article #7948Re: Language puzzle
From: Valentino Kyriakides
Date: Thu, 03 May 2001 06:58
Date: Thu, 03 May 2001 06:58
42 lines
2352 bytes
2352 bytes
John, well that's what I meant, but of course I'am not able to express it in a such nice english way than you did :-). Greetings Valentino "John McGrath [TeamB]" <ng-b@JPMcGrath.net> schrieb im Newsbeitrag news:3af0a403$1_2@dnews... > "Valentino Kyriakides" <vkyr@ision.net> wrote: > > > No, because their inner used scoping for the "String s" is different. I > > think, thus the second ones String should been initialized first. > > I think I understand what you are saying, in which case, it is pretty much > on target. If 's' were initialized before the first 'if' statement, they > would be equivalent. > > Java requires that all variables be "definitely assigned", which means that > the compiler must be able to verify, using relatively simple flow analysis, > that every variable will be assigned a value before it is used. > > The first example passes that test. The variable 's' is initialized on both > branches of the if-then-else, so it is definitely assigned. > > The second example does not. The compiler cannot examine the expressions > (b) and (!b) and determine that one of the two must be true, so 's' is not > definitely assigned. > > So the most obvious difference between the two methods is that the first one > will compile, but the second will get a compiler error on the return > statement. > > -- > Regards, > > John McGrath [TeamB] > > >
Technical Details
Message-ID:
<3af10232_2@dnews>Path:
arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!193.251.151.101!opentransit.net!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3aef3645_1@dnews> <3af06553$1_1@dnews> <3af0a403$1_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,b65cd5c59c7b0e70 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-05-03 00:08:47 PST From: "Valentino Kyriakides" <vkyr@nospamlavielle.com> Newsgroups: borland.public.jbuilder.java.language References: <3aef3645_1@dnews> <3af06553$1_1@dnews> <3af0a403$1_2@dnews> Subject: Re: Language puzzle Date: Thu, 3 May 2001 08:58:03 +0200 Lines: 44 Organization: ISION X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 NNTP-Posting-Host: 194.64.62.36 Message-ID: <3af10232_2@dnews> X-Trace: dnews 988873266 194.64.62.36 (3 May 2001 00:01:06 -0700) Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!193.251.151.101!opentransit.net!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews