Thread: Java Question
View Single Post
Old 02-26-2005, 04:37 PM   #2 (permalink)
gab00n
 
Super Techie

Join Date: Jan 2005

Posts: 295

gab00n

Default

Well it is like an if statement, it's name is the conditional operator in
C++, probably the same in java.

So if you wanted to convert it into an if statement it would look like this.
Code:
 
 if(h>= 0 && h < 24)
{
    hour = h;
}
else
{
    hour = 0;
}
It is very handy for keeping the code nice and neat, i use it very often as a result. So the stuff infront of the ? is the condition that must be met in order for it to be true and for hour to = h, the stuff after : is the false part and hour will be assigned 0.
__________________
\"Today\'s scientists have substituted mathematics for experiments, and they wander off through equation after equation, and eventually build a structure which has no relation to reality.\" Nikola Tesla
gab00n is offline