Java Learning notes-logical operators, bitwise operators, extension operators

Source: Internet
Author: User
Tags bitwise bitwise operators logical operators

Logical operators:

Logic and:&&

Logical OR: | |

Logical non-:!

Note: Logic and logic or the use of short-circuit methods. From left to right, if the determined value is no longer evaluated.

Eg:boolean c =1>2 && 2> (3/0); && does not report abnormal errors, stating that no 3/0 is executed;

Bitwise operators:

~ Reverse: 0 to 1 1 to 0

& Bitwise AND: 00 to 0, 01 to 0, 10 to 0, 11 to 1

| bitwise OR: 00 to 0, 01 to 1, 10 to 1, 11 to 1

^ Bitwise XOR: 00 to 0, 01 to 1, 10 to 1, 11 to 0 (same as 0, 1)

<< left shift operator: Shift left one is equivalent to multiply by 2.

>> Right shift operator: Move right one is equivalent to 2 fetch. (It is important to note that exams may be multiplied by 4 for the fastest or the most efficient by 4)

Expansion operators:

int A;

A + = 5; Equivalent to a = a +5;

a-=5; Equivalent to a = a-5;

a *=5; Equivalent to a = a*5;

a/=5; Equivalent to a = A/5;

A%=5//equivalent to a =a%5;

Java Learning notes-logical operators, bitwise operators, extension operators

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.