1The condition part of a ternary operator is followed by a question mark (?).
2After the question mark are the two values the ternary operator can return, separated by a colon (:).
3
4The values part consists of two values. The first value is returned if the condition parts evaluates to true.
5The second value is returned if the condition part evaluates to false.
1// variable= condition ? value if condition is True : value if condition is false
2// only ternary operator in java
3int max,a=1,b=2;
4max= a>b ? a : b;
5
6//will result in max = b
1booleanExpression ? expression1 : expression2;
2//expression1 if booleanExpression==true
3//expression2 if booleanExpression==false