Java based _Java increment decrement / relationship / logic / ternary operator

1  / * 
2      increment decrement operators
 3      relational operators
 4      Logical Operators
 5      ternary operator
 6      (same as C ++)
 . 7   * / 
. 8  public  class OperatorDemo01 {
 . 9      public  static  void main (String [] args) {
 10          / / increment decrement operators 
. 11          int I = 10 ;
 12 is          System.out.println ( "I:" + I); // 10
 13 is          // used alone
 14          // I ++ 
15          ++ I;
 16         System.out.println ( "i:" + i); // . 11
 . 17          // participate, use 
18 is          i = 10 ;
 . 19          int J = i ++; // i ++: first assigned to the value of i 10 j, then i + 1'd 
20 is          System.out.println ( "I:" + I); // . 11 
21 is          System.out.println ( "J:" + J); // 10 
22 is          I = 10 ;
 23 is          int K = I ++ ; // i ++: 10 first the value of i + 1, then the new value is assigned to the 11 K 
24          System.out.println ( "i:" + i); // 11 
25          System.out.println ( "K : "+ K); // . 11
 26 is 
27          // ! == relational operator, =,>,> =, <, <=: the results are boolean values: true or to false
 28  
29          // logical operators (& and) (| or) (^ ! XOR) (non)
 30          // shorting logical operators (&& shorted) (|| or shorted)
 31          // note the difference
 32          // && and &
 33 is          // || and | 
34 is          int I1 = 10, I2 10 = ;
 35          int J1 = 20 is, J2 = 20 is ;
 36          System.out.println ((I1 ++> 100) & (J1 ++> 100)); // to false to false & 
37 [          System.out.println ((I2 ++> 100) && (J2 ++> 100)); // to false to false && 
38 is          the System.out.println("i1: "+i1); // . 11 
39          System.out.println ( "I2:" + I2); // . 11 
40          System.out.println ( "J1:" + J1); // 21 is 
41 is          System.out.println ( "J2:" J2 +); @ 20 is
 42 is          // with C ++ (&& and ||) is not left to the right is performed is not satisfied
 43 is  
44 is          @ ternary operator
 45          // a> B a: B;? 
46 is  
47      }
 48 }

 

Guess you like

Origin www.cnblogs.com/NiBosS/p/11930384.html