🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7555

Re: How to do if/else on one line?

#7555
From: Alex Colic
Date: Wed, 06 Jun 2001 18:56
41 lines
1726 bytes
Thanks, thats exactly what I was looking for.

Alex
"J. David Boyd" <dave@tsc-corp.com> wrote in message
news:MPG.1586c2fedc60ad73989687@forums.borland.com...
> In article <3b1ce7b8$1_1@dnews>, alex.colic@pop-ware.com says...
> > Hi, I remember that there way a way to have an if-else statement all on
one
> > line. Something like:
> >
> > if(test) true, false;
> >
> > Can someone give me the syntax for this?
> >
> > Thanks
> >
> > Alex
> >
> >
> >
> You are talking about the ?: operator, used like
>
> <conditional> ? <if true clause> : <if false clause>
>
> so if you had
> ....
> int x = 0;
> System.out.println( x == 0 ? "Hello" : "Goodbye");
> x = 1;
> System.out.println( x == 0 ? "Hello" : "Goodbye");
> ....
>
> you would see:
>
> Hello
> Goodbye
>
>
> Dave
>
>
Technical Details
Message-ID: <3b1e7cdb$1_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-out.nibble.net!news-in.nibble.net!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews
References: <3b1ce7b8$1_1@dnews> <MPG.1586c2fedc60ad73989687@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,38b0f3260a20a9a4
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-06-06 12:03:53 PST
From: "Alex Colic" <alex.colic@pop-ware.com>
Newsgroups: borland.public.jbuilder.java.language
References: <3b1ce7b8$1_1@dnews> <MPG.1586c2fedc60ad73989687@forums.borland.com>
Subject: Re: How to do if/else on one line?
Date: Wed, 6 Jun 2001 14:56:25 -0400
Lines: 43
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 24.150.29.218
Message-ID: <3b1e7cdb$1_1@dnews>
X-Trace: dnews 991853787 24.150.29.218 (6 Jun 2001 11:56:27 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-out.nibble.net!news-in.nibble.net!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews