KnowledgeBoat Logo

Computer Applications

What is the use and syntax of a ternary operator?

Java Operators

ICSE 2009

49 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

31 Likes


Related Questions