class ConditionalDemo { public static void main(String[] args) { int value1 = 1; int value2 = 2; int result; result=(value1>value2) ? value1 : value2 ; System.out.println(result); } }
Output
2
Here in above program the expression (value1>value2) is false, so In this example, result will be assigned the value of value2 that is 2. This can be achieved using the if…….else statement as follows :
if(value1>value2) result=value1; else result=value2;
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc