Java computing priority, java priority
|
Column number |
Symbol |
Name |
Associativity (with operands) |
Number of projects |
Description |
|
1 |
. |
Point |
Left to right |
Binocular |
|
|
() |
Parentheses |
Left to right |
|
|
|
[] |
Square brackets |
Left to right |
|
|
|
2 |
+ |
ID |
From right to left |
Single Camera |
|
|
- |
Negative number |
From right to left |
Single Camera |
|
|
++ |
Auto-Increment |
From right to left |
Single Camera |
Prefix and suffix |
|
-- |
Auto-Subtraction |
From right to left |
Prefix subtraction and suffix Subtraction |
|
~ |
Bitwise non/complement operation |
From right to left |
Single Camera |
|
|
! |
Non-logical |
From right to left |
Single Camera |
"!" Cannot be used with "=" |
|
3 |
* |
Multiplication |
Left to right |
Binocular |
|
|
/ |
Division |
Left to right |
Binocular |
Integer Division: the integer part of the operator. The fractional part is removed without rounding. |
|
% |
Remainder |
Left to right |
Binocular |
|
|
4 |
+ |
Add |
Left to right |
Binocular |
|
|
- |
Subtraction |
Left to right |
Binocular |
|
|
5 |
< |
Left Shift Operator |
Left to right |
Binocular |
|
|
> |
Right Shift Operator with symbol |
Left to right |
Binocular |
|
|
>>> |
Unsigned right shift |
Left to right |
Binocular |
|
|
6 |
< |
Less |
Left to right |
Binocular |
Description of the relational operator "greater" |
|
<= |
Less than or equal |
Left to right |
Binocular |
|
|
> |
Greater |
Left to right |
Binocular |
|
|
> = |
Greater than or equal |
Left to right |
Binocular |
|
|
Instanceof |
Determines whether an object belongs to a specified class. |
Left to right |
Binocular |
|
|
7 |
= |
Equal |
Left to right |
Binocular |
Description of the relational operator "=" |
|
! = |
Not equal |
Left to right |
Binocular |
|
|
8 |
& |
Bitwise AND |
Left to right |
Binocular |
|
|
9 |
| |
By bit or |
Left to right |
Binocular |
|
|
10 |
^ |
Bitwise OR |
Left to right |
Binocular |
|
|
11 |
&& |
Short circuit and |
Left to right |
Binocular |
|
|
12 |
| |
Short circuit or |
Left to right |
Binocular |
|
|
13 |
? : |
Conditional Operators |
From right to left |
Tri-category |
|
|
14 |
= |
Value assignment operator |
From right to left |
Binocular |
|
|
+ = |
Mixed value assignment operator |
|
|
-= |
|
|
* = |
|
|
/= |
|
|
% = |
|
|
& = |
|
|
| = |
|
|
^ = |
|
|
<= |
|
|
>>= |
|
|
>>>= |
|
Note:
1. Arithmetic Operators
+: Addition
-: Subtraction
*: Multiplication
/: Division
%: Remainder operation
2. Relational operators
<: Only the relationships between basic data types can be compared, and the relationships between objects cannot be compared.
>:( Same-relation operator "<")
<=: (Same-relation operator "<")
>=: (Same relational operator "<")
=: If you use this operator to compare the references (variables) of two objects, it is essentially to compare whether two variables reference the same object. The same object refers to whether the object is stored in the same memory unit opened in the stack (Heap.
If the content of the objects referenced by the references (variables) of two objects is the same, the equals () method should be used. The return value type of this method is a Boolean value. Note: If you use a class in the class library to create an object, the equals () method is called to compare the object content. If you use a custom class to create an object, the equals () method is called to compare whether two references reference the same object. In the second case, the equals () method compares references by default.
! = :( Equal relational operator "= ")
3. logical operators (operators can only be boolean)
&&
|
!
1 public class Demo {2 public static void main (String [] args) {3 // System. out. println ((! '1' | '1') + 5); // compilation error 4 // System. out. println (! 5); // compilation error 5 // System. out. println ('1' | '1') + 5); // compilation Error 6 // System. out. println (1 | 2); // compilation error 7 // System. out. println (5-3 | 4-2); // compilation error 8 System. out. println (5 <3 | 4> 3); // true 9} 10}
4. bitwise operators
&
|
^
! : Cannot be used with =, because! It is a one-dimensional operator. It is not allowed to perform bitwise non-operations on boolean data.
5. Shift Operators (only integer operators can be processed)
Char, byte, and short types will be converted to int type before the shift, and the result after the shift is also int type; the right operand of the shift symbol only truncates the last five digits of its binary value (the purpose is to prevent the shift operation from exceeding the int-type representation range: The power 5 of 2 is 32, the maximum value of the int type is 32 bits). If the long type is shifted, the result is still long. The operator on the right of the shift symbol only truncates the last 6 bits of the binary.
<:
>>: If the sign bit is positive, 0 is inserted in the highest bit. If the sign bit is negative, 1 is inserted in the highest bit.
>>>: No matter whether positive or negative, 0 is inserted at the highest bit.
1 public class Demo { 2 public static void main(String[] args) { 3 // 0000 0000 0000 0101 4 // 0000 0000 0000 0010 5 System.out.println(5>>1);//2 6 // 0000 0000 0000 1000 7 // 0000 0000 0000 0100 8 System.out.println(8>>1);//4 9 System.out.println(3+5>>1);//410 System.out.println(3+(5>>1));//511 }12 }