Java Ternary Operator

In this tutorial you will learn about the Java Ternary Operator and its application with practical example.

Java Ternary Operator ( ? : )

In Java, conditional or ternary operator is considered as short hand for java if else statement. Conditional operator is also called as “Ternary Operator”.

Syntax:

If condition is true the expression will return result1, if it is not it will return result2.

Example:-

Output:-

java_ternary_operator_example

Recommended:-  Java if else statement
In this tutorial we have learn about the Java Ternary Operator and its application with practical example. I hope you will like this tutorial.