·  JAVA – Syntax – Conditional Statements – Question ?:

 

- Info:

  - This tutorial shows how to use "?:" operator in Java.

 

- Program Flow:

  - The condition, (a > b), is tested.

  - If it is true the first value, a, is returned.

  - If it is false, the second value, b, is returned.

 

- Procedure:

  - Create JAVA Console Application Test.java

 

    Test.java

    public class Test {

   

      public static void main(String[] args) {

        

        int a   = 10;

        int b   = 5;

   

        int max = (a > b) ? a : b; 

        System.out.println(max);

     

      }

   

    }