A Operator. 1. Arithmetic operator: +,-, *,/,%2. Self-increment: + +,--
+ + is evaluated before the assignment
+ + after assigning the value after the operation
-Minus minus.
3. Assignment operator: =, +=,-=,*=,/=4. Relational operator: >,<,>=,<=,==,!=5. Logical operators: &, | ,! ,&&, | | 6. Bitwise operators: (1). The symbol for the bitwise operator:
& (with): Both are 1 when I am one, the others are 0
| (OR): Both are 0 o'clock to 0, and the others are 1.
^ (XOR): The difference between the two is 1, the same as 0
~ (Inverse): 0 becomes 1, 1 becomes 0.
(2). Negative representation: The highest bit of bits is 1, then this number is a negative.
-1:1111-1111 1111-1111 1111-1111 1111-1111
0:0000-0000 0000-0000 0000-0000 0000-0000
-2:1111-1111 1111-1111 1111-1111 1111-1110
-3:1111-1111 1111-1111 1111-1111 1111-1101
-4:1111-1111 1111-1111 1111-1111 1111-1100
-5:1111-1111 1111-1111 1111-1111 1111-1011
-6:1111-1111 1111-1111 1111-1111 1111-1010
-7:1111-1111 1111-1111 1111-1111 1111-1001
7:0000-0000 0000-0000 0000-0000 0000-0111
Rule: Negative number corresponding to the positive number-1, the inverse negative number corresponding to the positive number reversed +1
(3). Shift Operator: operation on Bits
>> Right Shift
<< left Shift
>>> Unsigned Right Shift
Move right:
System.out.println (6>>1); --->3 6/2 2*1
System.out.println (6>>2); --->1 6/4 2*2
System.out.println (6>>3); --->0 6/8 2*3
System.out.println ( -6>>1); -6/2-->-3
Rule: Shift the number of digits to the right by dividing by 2 how many times you need to move. Move Left:
System.out.println (6<<1); --->12 6*2 2*1
System.out.println (6<<2); --->24 6*4 2*2
System.out.println (6<<3); --->48 6*8 2*2*2
System.out.println (6<<4); ---->96 6*16 2*2*2*2
System.out.println ( -6<<2);//--->-24
//Law: How many digits to the left, multiply this number by 2 times. >>> unsigned Right shift feature: No matter if your highest bit is 0 or 1, the vacancy is 0.
System.out.println (6>>>1); 3
System.out.println (6>>>2); 1
System.out.println ( -6>>>2); 1073741822
Function: Increase the operation rate. Bit arithmetic is the fastest execution. Features: A number A and two the same number ^, the final result is still the original number A.
Basic knowledge Operators for Java