The "Java" operator

Source: Internet
Author: User

The Java operator is divided into four categories:

Arithmetic operators, relational operators, logical operators, bitwise operators.

Arithmetic operator (9): +-*/% + +--

Relational operators (6): = = = = > >= < <=

Logical operator (6):&& (with short circuit) | | (or short-circuit)! ^ (XOR) & (with) | (OR)

Bitwise operators (7):& (with operations) | (or operation) ~ (inverse code) ^ (XOR) >> (shift right) << (shift left) >>> (unsigned Right shift)

&: There is a false, that is false

|: There is a truth, that is true

^: The difference is true, the same is false

A number or a number two times, the result is still that number. such as 7^4^4=7 (can be used in encryption, 4 is the secret key)

& and && differences:

2>3 & 2<6: Either True or false on the left, the right side participates in the operation

2>3 && 2<6: When the left is false, the right side does not participate in the operation

| and | | Difference:

2>3 | 2<6: Whether true or false on the left, the right side participates in the operation

2>3 | | 2<6: When the left is true, the right side does not participate in the operation

<<: Multiplied by 2 of the number of moving bits, such as 3<<2=3*2 2 (2-bit moving) =12

>>: Divided by 2 by the number of moves of the power, such as 6<<2=6/2 2 (moving 2-bit) The second square =1

>> and >>> differences:

>>: The maximum number of bits is determined by the highest bit value of the original data.

>>>: No matter what the highest bit is, after the right move, use 0 to fill.

The "Java" operator

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.