Java View all facts Glossary Help |
syntactic unit > symbol > operator > ?: |
?: (conditional operator) | ||||
subject | fact |
?: | can shorten code but can also make code harder to understand | |
has right to left associativity | ||
has purpose to evaluate the expression on the left and return one value if the expression is true and a different value if the expression if false | ||
has syntax result = (condition) ? doSomething() : doSomethingElse();If condition is true, then result is set to the expression following the question mark, otherwise result is set to the expression following the colon | ||
has syntax expression ? op1 : op2 | ||
is a subtopic of Operators | ||
is an instance of operator | ||
is an instance of tertiary operator | ||
returns the value of the selected expression | ||
is a synonym of conditional operator | ||
operator | evaluates to its result | |
is part of an expression | ||
is evaluated before another operator with lower precedence | ||
syntactic unit | has syntax rule bold = mandatory |