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, a conditional or ternary operator is considered shorthand for a java if-else statement. The conditional operator is also called as “Ternary Operator”.

Table Of Contents

Syntax:

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

Example:-

Output:-

java_ternary_operator_example

In this tutorial we have learn about the Java Ternary Operator and its application with practical example. I hope you will like this tutorial.