What is java ternary operator
Here mention example which helps to understand the concept of the java ternary operator.
public class TernaryOperator {
public static void main(String[] args) {
int a=10;
int b=20;
int min= a<b ? a:b;
int max= a>b ? a:b;
System.out.println(min);
// first case the condition is true so return the value of a
System.out.println(max);
// second case the condition is false so return the value of b
}
}
I hope guys you understand the concept of the java ternary operator if you any query regarding this operator so please mention in the comment section i will try to solve this answer
Tags:
operator