-4

I do not understand what this statment is doing.

(minute==minuteFloor+1 ? TIME_PICKER_INTERVAL : 0)

could someone explain it or provide a link

Thank you.

Adam Arold
  • 29,285
  • 22
  • 112
  • 207
user2708296
  • 33
  • 1
  • 2
  • 10

2 Answers2

4

It's basically

if(minute == minuteFloor + 1) {
 val = TIME_PICKER_INTERVAL;
} else {
 val = 0;
}
claudio
  • 1,465
  • 16
  • 26
  • Almost, but not quite, `Number n=(true?1:1.5);` will have `n` of type Double so the two are not strictly equivalent. See [here](http://stackoverflow.com/questions/19729588/wrong-type-in-java-conditional-assignment) for more details – Richard Tingle Nov 07 '13 at 17:27
0
myvariable  =   (minute==minuteFloor+1 ? TIME_PICKER_INTERVAL : 0)

In the above statement you used ?: operator which is called Ternary Operator.

it is used in below context:

if(condition)
{
//assign some value
}
else
{
//assign some other value
}

so your code does similar to below:

if(minute==minuteFloor+1)
{
myvariable=TIME_PICKER_INTERVAL;
}
else
{
myvariable=0;
}
Sudhakar Tillapudi
  • 25,935
  • 5
  • 37
  • 67