Java operator Precedence

Source: Internet
Author: User
Tags bitwise

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.