It is depends on the boolean expression is true or false. the main motive of this expression is which value should be assign .

 expression :    variable  x=(expression)  ?  true value  :  false value

Source Code:
  1. public class ConditionalDemo {
  2. private static Scanner input;
  3. public static void main(String[] args) {
  4. input = new Scanner(System.in);
  5. int num1,num2,large;
  6. System.out.print("Enter two number: ");
  7. num1 = input.nextInt();
  8. num2 = input.nextInt();
  9. large = (num1>num2)?num1:num2;
  10. System.out.println("large no is ="+large);
  11. }
  12. }
Output:
        
          Enter two number: 25 24
          large no is =25

Enter two number: 50 55
large no is =55

0 comments:

Post a Comment