ternary operator

(? :) Conditional/Ternary Operator in Java – Programming Example

In this chapter you will learn:

  1. What is conditional or ternary operator in java
  2. Programming example 

    ternary operator


What is conditional or ternary operator in java?

Symbol of Ternary operator is (?:) and it is also known as ternary operator. This operator works on 3 operands and simply minify your code by removing if else clause.

Syntax of ternary operator:

 Programming Example:


D:\JavaProgram>javac TernaryOperator.java

D:\JavaProgram>java TernaryOperator

D:\JavaProgram> __


In this chapter you have learned what conditional or ternary operator in Java is. You have also learned a programming example of conditional operator. In the next chapter you will learn about Bitwise Operator in Java.

Leave a Reply

Your email address will not be published. Required fields are marked *