自增 自减运算符 public class Demo{ public static void main(String() args){ int a = 3; int b = a++;//执行完这行代码后,先给b赋值,再自增 //a = a+1 System.out.println(a);// 输出4 // a = a+1 int c = ++a;//执行完这行代码前,先自增,再给c赋值 System.out.println(a);//输出5 System.out.println(b);//输出3 System.out.println(c);//输出5 //幂运算 Math方法 2^3 2*2*2 = 8 double pow = Math.pow(3,2); System.out.println(pow);//输出值为8 } } l逻辑运算符 public class Demo1{ public static void main(String() args){ //&&与(and) ||与(or) !非(取反) boolean a = ture; boolean b = false; System.out.println("a && b :"+(a&&b));//输出值为false 与&&运算 两个变量都为真 结果才为ture System.out.println("a || b :"+(a&&b));//输出值为ture 或||运算 两个变量有一个为真 结果为ture System.out.println("!(a && b) :"+!(a&&b));//输出值为ture 非! 如果是真 则变为假 如果是假则变为真 //短路运算 如果与运算 开始执行就为false 则后面的不执行 int c = 5; boolean d = (c<4)&&(c++<4); System.out.println(d);// false System.out.println(c);// 值为5 } }