import java.util.Scanner; public class Conditional /** This class demonstrates Conditional operator * */ { public static void main(String[] args) { int num1=10, num2=20, max; // checking a condition, based on truth of the condition, we // are assigning a value to a variable if (num1 > num2) { max = num1; } else { max = num2; } System.out.println("max is " + max); // equivalent just using a different construct max = num1 > num2 ? num1 : num2; // ?: // boolean expr ? value_if_true : value_if_false // another example: int tuition = income<120000 ? 0 : 5000; } }