Ternary operator in Java

output is small number

The ternary operator is a simple conditional branching statement. It returns a value based on condition.

num > 100 ? is our condition.

"big number" the first value(before :) will be returned if a condition is true.

"small number" the second value(after :) will be returned if a condition is false. In our case, this value is returned because the condition is false.

Turnery operator can be used with any other data types as well.

Software Developer, Java Instructor https://www.techleadacademy.io/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store