conditional operator in java example
Example 1: condition operator in java
b = (a == 1) ? 20: 30;
Example 2: ternary operator java
variable = (condition/expression1) ? expression2 if true : expression3 if false
b = (a == 1) ? 20: 30;
variable = (condition/expression1) ? expression2 if true : expression3 if false