Learn from: http://lasombra.iteye.com/blog/991662
http://blog.csdn.net/xiaoli_feng/article/details/4567184
Monocular multiplication is the relationship, and the logic is assigned after three eyes.
Monocular: monocular operator +– (negative) + +--et
Multiplication: Arithmetic monocular operator */% +-
As: Displacement monocular operator << >>
Relationships: Relational Monocular operators > < >= <= = = = =
Logic: Logical Monocular operators && | | & | ^
Trinocular: Three mesh single-mesh operators a > B? X:y
After: Meaningless, just to make up the number of words
Assignment: Assigned value =
Operator Precedence Table
Priority level |
Operator |
Binding nature |
1 |
() [] . |
From left to right |
2 |
! + (positive)-(negative) ~ + +-- |
From right to left |
3 |
* / % |
From left to right |
4 |
+ (plus)-(minus) |
From left to right |
5 |
<< >> >>> |
From left to right |
6 |
< <= > >= instanceof |
From left to right |
7 |
== != |
From left to right |
8 |
& (Bitwise AND) |
From left to right |
9 |
^ |
From left to right |
10 |
| |
From left to right |
11 |
&& |
From left to right |
12 |
|| |
From left to right |
13 |
?: |
From right to left |
14 |
= + = = *=/=%= &= |= ^= ~= <<= >>= >>>= |
From right to left |
Note: 1. The priority in the table is written in order from highest to lowest, that is, Priority 1 is the highest priority, and priority 14 has the lowest priority level. 2. Binding is the order in which operators are combined, usually from left to right. The most typical right-to-left operator is the minus sign, such as 3+-4, meaning 3 plus-4, with the symbol first combined with the content on the right side of the operator. 3, instanceof function is to determine whether the object is a class or interface type, followed by detailed introduction. 4, pay attention to distinguish between the sign and plus minus, and the difference between the bitwise AND and logical and the actual development, do not need to go to the memory operator priority, do not deliberately use the operator's priority, for the unclear priority place using parentheses to replace, example code: int m = 12; int n = m << 1 + 2; int n = m << (1 + 2); This is more intuitive and easy to maintain
Java operator Precedence