JavaSE 第五讲 Operater cont. 9.24

1.关系运算符

public class OperatorTest
{
   public static void main(String[] args)
  { 
           int a = 3;
           int b = 2;
         
           boolean c = a > b;

           System.out.println(c);
  }
}

2.逻辑运算符及逻辑运算符的短路

  public class LogicTest
 {
        public static void main(String[] args)
       {
            int a = 1;
            int b = 2;
            int c = 3;
            int d = 4;

            /*
            boolean e = (a < b)&&(c < d);
            System.out.println(e);
            */
            boolean e = (a < b)||(c < d);
            System.out.println(e);
        }

}

—————————————————————————————————

public class LogicTest2
{
    public static void main(String[] args)
    {
            int a = 1;
            int b = 2;
            int c = 3;
            int d = 4;
            int f = 5;

            //boolean e = (a < b)&&((f = c) < d);
            boolean e = (a > b)&&((f = c) < d);
            
            //System.out.println(e);
            //System.out.println(f);

            //boolean g = (a < b)||((f = c) < d);  
            boolean g = (a > b)||((f = c) < d); 

            System.out.println(g);
            System.out.println(f);
    }

}

3.变量的自增和自减

public class Variable
{
    public static void main(String[] args)
    {
             int a = 3;
             //a = a + 1;

             //a += 1;//等价于a = a + 1;
             //a++;
             // ++a;

             //int b = a++;
             int b = ++a;

             a++;
             --a;
             --a;

             System.out.println(a);
             System.out.println(b);
    } 
}

你可能感兴趣的:(JavaSE 第五讲 Operater cont. 9.24)