Article View: borland.public.jbuilder.java.language
Article #7933Re: Language puzzle
From: Ivo B. Limmen
Date: Wed, 02 May 2001 12:57
Date: Wed, 02 May 2001 12:57
40 lines
2059 bytes
2059 bytes
It's almost the same...except that the first one is more efficient because
it uses one IF statement. Doing a compare operation (IF) causes the
processor to let go of the other pine-lines (in an intel Pentium III there
are 3 pipe-lines).
I am not aware of any code optimalisation in the Java Virtual Machine but it
should be more effecient to use one IF statement.
Ivo
"John McGrath [TeamB]" <ng-b@JPMcGrath.net> wrote in message
news:3aef3645_1@dnews...
> Here is an interesting little language question:
>
> Are the following two methods equivalent?
>
> String booleanString( boolean b ) {
> String s;
> if ( b ) {
> s = "true";
> } else {
> s = "false";
> }
> return s;
> }
>
> And:
>
> String booleanString( boolean b ) {
> String s;
> if ( b ) s = "true";
> if ( !b ) s = "false";
> return s;
> }
>
> --
> Regards,
>
> John McGrath [TeamB]
>
>
Technical Details
Message-ID:
<9cp0a3$7bu$1@porthos.nl.uu.net>Path:
arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com!europa.netcrusader.net!195.238.2.15!skynet.be!newsfeed1.news.nl.uu.net!sun4nl!reader1.news.nl.uu.net!not-for-mailReferences:
<3aef3645_1@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-02 06:00:03 PST Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com!europa.netcrusader.net!195.238.2.15!skynet.be!newsfeed1.news.nl.uu.net!sun4nl!reader1.news.nl.uu.net!not-for-mail From: "Ivo B. Limmen" <limmen@furore.nl> Newsgroups: borland.public.jbuilder.java.language Subject: Re: Language puzzle Date: Wed, 2 May 2001 14:57:43 +0200 Organization: UUNET-NL (http://www.nl.uu.net) Lines: 42 Message-ID: <9cp0a3$7bu$1@porthos.nl.uu.net> References: <3aef3645_1@dnews> NNTP-Posting-Host: 1cust34.tnt3.rtm1.nl.uu.net X-Trace: porthos.nl.uu.net 988808323 7550 213.116.100.34 (2 May 2001 12:58:43 GMT) X-Complaints-To: abuse@nl.uu.net NNTP-Posting-Date: 2 May 2001 12:58:43 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400