You don't evaluate an if statement. You can't assign a variable to the evaluation of a switch statement.
These are all control-flow constructs. They control which statements are run and when.
(Assignment statements are ironically expressions, though one could argue that every expression is also a statement in Java).
cond ? exprtrue : exprfalseThis is called the conditional expression or the question mark-colon operator.
The two expressions, exprtrue, exprfalse should evaluate to the same type.
One major difference between method calls and operators is that method calls always evaluate each argument. However, an expression with operators may not always evaluate each operand (an operand is basically an argument). In particular, &&, ||, and the conditional expression do not always evaluate each operand. (Recall && and || short circuits depending on the evaluation of the left operand, which may cause the right operand to be unevaluated).
public int absVal( int x ) { return x > 0 ? x : -x ; }This checks to see if x is positive. If so, it evaluates x and returns it. If false, it evaluates -x and returns that. This negates a negative number (or zero), and evaluates to a positive number (or zero).
Notice at most one of the two expressions, x and -x, is evaluated. Both expressions are never evaluated.
Oh, you can also nest the operators, though it's a bit awkward looking. That is, exprtrue and exprfalse can themselves be conditional expressions, if you want. This may require parentheses to avoid problems with precedence.