1.自增,自减运算符
public class Demo05 {
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
}
}
2.位运算符
public class Demo06 {
public static void main(String[] args) {
/*
A = 0011 1100
B = 0000 1101
------------
A&B = 0000 1100 与
A|B = 0011 1101 或
A^B = 0011 0001 异或
~B = 1111 0010 取反
2*8 = 2*2*2*2 = 16
效率很高
<< *2
>> /2
0000 0000 0
0000 0001 1
0000 0010 2
0000 0011 3
0000 0100 4
0000 1000 8
0001 0000 16
*/
System.out.println(2<<3);//16
}
}