KnowledgeBoat Logo

Computer Applications

What is the use and syntax of a ternary operator?

Java Operators

ICSE 2009

45 Likes

Answer

Ternary operator is used to check if a condition is true and false. Depending on whether the condition tests true or false, expression 1 or expression 2 is evaluated. Its syntax is:

boolean-expression ? expression1 : expression2;

Answered By

28 Likes


Related Questions