Wiki Markup |
---|
The conditional operator {{?:}} uses the {{boolean}} value of one expression to decide which of the other two expressions should be evaluated \[[JLS 052005|AA. Java References#JLS 05]\]. The conditional operator is syntactically right-associative. For instance {{a?b:c?d:e?f:g}} is equivalent to {{a?b:(c?d:(e?f:g))}}. |
...
Wiki Markup |
---|
This noncompliant code example uses boxed and unboxed primitives of different types in the conditional expression. Consequently, the {{Integer}} object is auto-unboxed to its primitive type {{int}} and coerced to the primitive {{float}}. This results in loss of precision. \[[Findbugs 082008|AA. Java References#Findbugs 08]\] (sic) |
...
References
Wiki Markup |
---|
\[[JLS 052005|AA. Java References#JLS 05]\] [Section 15.25, Conditional Operator ? :|http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.25] \[[Bloch 052005|AA. Java References#Bloch 05]\] Puzzle 8: Dos Equis \[[Findbugs 082008|AA. Java References#Findbugs 08]\] "Bx: Primitive value is unboxed and coerced for ternary operator" |
...