Ternary


Java

The ternary operator uses three operands. It's like f(b, e1, e2) where b is a Boolean expression, and e1 and e2 are of any type so long as they match each other.

Syntax: b? e1 : e2.

For example, for absolute values, you would evaluate differently depending on whether you are entering a positive or negative number.

(IT.1.1x)