?和:是Java条件运算符的一部分。有时称为三元运算符,因为它是Java中唯一带有3个参数的运算符。
这本质上是一个内联IF / THEN / ELSE块。
_permanence = permanence==0.0 ? INITIAL_PERMANENCE : (float)Math.min(1.0,permanence);
可以重写如下:
if (permanence == 0.0) _permanence = INITIAL_PERMANENCE;else _permanence = (float) Math.min(1.0,permanence);
条件运算符的一般形式是
<Test returning a boolean> ? <value for if test is true> : <value for if test is false>



