Java ternary operator

1  public  class the Test {
 2      public  static  void main (String args []) {
 . 3          int a, B;
 . 4          a = 10 ;
 . 5  
. 6          B = (a == 1) 20 is:? 30 ;
 . 7          // if a is equal to 1 then b is equal to 20, or equal to 30 
. 8  
. 9          System.out.println ( "the Value of b IS:" + b);
 10          b = (A == 10) 20:? 30 ;
 . 11          System.out.println ( " B IS of the Value: "+ B);
 12 is  
13 is      }
 14  }
 15  
16  output:
17 Value of b is : 30
18 Value of b is : 20

 

Guess you like

Origin www.cnblogs.com/liyihua/p/11668389.html