[Solved] Java ternary operator does not compile as a statement [duplicate]


The conditional is not simply equivalent to an if-else statement.

From the specification for the Conditional Operator ?:

The conditional operator has three operand expressions. ? appears between the first and second expressions, and : appears between the second and third expressions.

The first expression must be of type boolean or Boolean, or a compile-time error occurs.

It is a compile-time error for either the second or the third operand expression to be an invocation of a void method.

1

solved Java ternary operator does not compile as a statement [duplicate]