30 40 30 300 30 10
位与运算符(&)
运算规则:两个数都转为二进制,然后从高位开始比较,如果两个数都为1则为1,否则为0。
比如:10&30.
10转换成二进制就是01010,30转换成二进制就是11110。从高位开始比较得到,得到01010,即10.
public class HelloWorld{ public static void main(String[] args) { int one = 10 ; int two = 20 ; int three = 0 ; three =one+two; System.out.println(three); //three=0; three+=one; System.out.println(three); //three=0; three-=one; System.out.println(three); //three=0; three*=one; System.out.println(three); //three=0; three/=one; System.out.println(three); //three=0; three &=one; System.out.println(three); } }
厉害的一个一个敲空格,这排版跟shi一样
public class HelloWorld{ public static void main(String[] args) { int one = 10 ; int two = 20 ; int three = 0 ; three =one+two; System.out.println(three); //three=0; three+=one; System.out.println(three); //three=0; three-=one; System.out.println(three); //three=0; three*=one; System.out.println(three); //three=0; three/=one; System.out.println(three); //three=0; three &=one; System.out.println(three); }}
代码如下