Conditional operator in Java [duplicate]

expression ? value 1 : value 2

if expression is true, result is value 1 (first condition)

if expression is false ,result is value 2(second condition)

Example:

x = 1, x > 10 ? x : 10

expression: x > 10 => false

value 1: x
value 2: 10

result is 10

Browse More Popular Posts

Leave a Comment