Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

can't understand a java statement - please help

Thread view: 
Moham12345 - 19 Mar 2007 03:49 GMT
hi,
im converting a program and can't understand a statement please can
you help

this is the statement

double s_star = (s_star_raw > s0) ? s_star_raw : s0;

so ok.. .if

s_star_raw = 15
s0 = 3

what is s_star?

thank you for helping.
Jeff Higgins - 19 Mar 2007 03:56 GMT
> hi,
> im converting a program and can't understand a statement please can
[quoted text clipped - 12 lines]
>
> thank you for helping.

if s_star_raw is greater than s0 then s_star equals s_star_raw otherwise
s_star equals s0
Jeff Higgins - 19 Mar 2007 04:26 GMT
>> hi,
>> im converting a program and can't understand a statement please can
[quoted text clipped - 15 lines]
> if s_star_raw is greater than s0 then s_star equals s_star_raw otherwise
> s_star equals s0

also see Conditional Operator (?:)
http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.25
Tom Hawtin - 19 Mar 2007 05:22 GMT
> if s_star_raw is greater than s0 then s_star equals s_star_raw otherwise
> s_star equals s0

Or to put it more sensibly:

    double sStar = Math.max(sStarRaw, s0);

Tom Hawtin
Sherm Pendley - 19 Mar 2007 05:30 GMT
> im converting a program and can't understand a statement please can
> you help
>
> this is the statement
>
> double s_star = (s_star_raw > s0) ? s_star_raw : s0;

The expression "(test) ? true_value : false_value" evaluates to true_value
if test is true, or false_value if not.

In other words, the above is equivalent to this:

   double s_star;
   if (s_star_raw > s0) {
       s_star = s_star_raw;
   } else {
       s_star = s0;
   }

sherm--

Signature

Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net

Ian Shef - 18 Apr 2007 20:40 GMT
"Moham12345" <m_w_raza@hotmail.com> wrote in news:1174272582.727537.164780
@y80g2000hsf.googlegroups.com:

> hi,
> im converting a program and can't understand a statement please can
[quoted text clipped - 12 lines]
>
> thank you for helping.

I could give you the answer, but then what would you learn?  Here is a
clue.

The expression

a?b:c

provides a value of "b" if "a" is true, otherwise it provides a value of
"c".

(The double quotes I used are meant as separators and not as indicators of
a String).

This should be enough of a clue to figure it out.  If not, then you had
better back up and study Java some more.

Good Luck!

Signature

Ian Shef     805/F6      *    These are my personal opinions    
Raytheon Company         *    and not those of my employer.
PO Box 11337             *
Tucson, AZ 85734-1337    *



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.