Java Ternary Operator

Ternary Operator is also known as the Conditional operator. It is used to evaluate Boolean expressions. We can say that it is a short version of the if-else statement. But here instead of operating on to operand, it operates on three operands, and therefore the name ternary.

Syntax: of Ternary Operator:

Example of Ternary Operator :

Output: