Java basic----> operators and their precedence

Source: Internet
Author: User
Tags bitwise

One, operator

1) '/' division operator

A) If it is divided by two integers, take only the integer quotient, such as 7/2=3

b) If the number is divided by a floating-point number, the floating-point number is a quotient, such as 7/2f=3.5

2) Self-increment, decrement operator "+ +""--"

A) operands using the self-increment or decrement operator must be integers or floating-point numbers,char and Boolean cannot use "+ +""-- "

3) Comparison operators, note the desirable types of operands of these operators

4) Logical operators &&,&,| | ,!

A) operands of these logical operators must be of type Boolean

b) && and & both represent logic and, but the two operators are different, the former is a short-circuit operator, sometimes omit some of the calculation steps,

5) Bitwise operator

A) & | ~ ^ Bitwise XOR (two values do not simultaneously result 1) << >> >>> unsigned Right shift

b) << left shift, left to move empty partial complement 0

c) >> right SHIFT, signed right SHIFT, if the highest bit is 1, the right part of the blank is shifted 1

If the highest bit is 0, the right part of the blank is shifted 0

d) >>>, right shift, unsigned right shift, whether the change is 0 or 1, the right to move the empty part of the complement 0

e) The operand types that the shift operator applies to are byte, short,int,long, Char

f) A number <<n bit, equivalent to this time multiplied by 2^n; a number >>n , equivalent to this number divided by 2. ^n

Ii. precedence of Operators

Overview: Operators have a certain priority and priority determines the order of execution

If two operators in the same expression have the same precedence, the left-behind operator is executed.

When programming, you should use parentheses to limit the order of operations, so as to avoid errors.

Java basic----> operators and their precedence

Related Article

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.