Java   View all facts   Glossary   Help
syntactic unit > symbol > operator > ?:
Next operatorarithmetic operator    Upoperator, tertiary operator    Previous operator.   

?:
(conditional operator)
subjectfact 
?:can shorten code but can also make code harder to understand    source: Object Oriented Software Engineering by Lethbridge and Laganière, 2001-10-19 11:35:49.0
has right to left associativityadded by: Judy, source: Java in a Nutshell, 2001-10-19 11:35:49.0
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    added by: JK, source: Sun Java Tutorial, 2001-10-19 11:35:49.0
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   
source: Object Oriented Software Engineering by Lethbridge and Laganière, 2001-10-19 11:35:49.0
has syntax
expression ? op1 : op2
added by: JK, source: Sun Java Tutorial, 2001-10-19 11:35:49.0
is a subtopic of Operators2001-10-19 11:35:49.0
is an instance of operatoradded by: JK, source: Sun Java Tutorial, 2001-10-19 11:35:49.0
is an instance of tertiary operatoradded by: JK, source: Sun Java Tutorial, 2001-10-19 11:35:49.0
returns the value of the selected expressionadded by: JK, source: On To Java, 2001-10-19 11:35:49.0
is a synonym of conditional operator2001-10-19 11:36:31.0
operatorevaluates to its result2001-10-19 11:37:36.0
is part of an expression2001-10-19 11:37:36.0
is evaluated before another operator with lower precedence2001-10-19 11:37:36.0
syntactic unithas syntax rule
bold = mandatory
italic = non-terminal
normal font = optional
2001-10-19 11:38:04.0