1,运算符和使用以及二进制的转化
public static void main(String[] args) {
int a = 100;
int b = 97;
System.out.println(Integer.toBinaryString(a)); // 1100100
System.out.println(Integer.toBinaryString(b)); // 1100001
System.out.println("------------------位运算符 与------------------");
int r1 = a & b;
System.out.println(r1); // 96
System.out.println(Integer.toBinaryString(r1)); // 1100000
System.out.println("------------------位运算符 或------------------");
int r2 = a | b;
System.out.println(r2); // 101
System.out.println(Integer.toBinaryString(r2)); // 1100101
System.out.println("------------------位运算符 异或------------------");
int r4 = a ^ b;
System.out.println(r4); // 5
System.out.println(Integer.toBinaryString(r4)); // 101
System.out.println("------------------位运算符 非--------------------");
int r3 = ~a;
System.out.println(r3); // -101
System.out.println(Integer.toBinaryString(r3)); // 11111111111111111111111110011011
System.out.println("------------------位运算符 右移------------------");
int r5 = a >> 1;
System.out.println(r5); // 50
System.out.println(Integer.toBinaryString(r5)); // 110010
System.out.println("------------------位运算符 左移------------------");
int r6 = a << 1;
System.out.println(r6); // 200
System.out.println(Integer.toBinaryString(r6)); // 11001000
}