Basic operators, remainder, logical operators, logical operators, bitwise operators, shift operators in Java

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

Precautions:

    1. Constants are assigned at compile time, and variables are allocated in memory when they are run.
    2. Assignment operator + =-+ *+%= \= The Java compiler enforces type conversions

Residual:

In Java, it is time to take the remainder operation, and the sign of the result is determined by the divisor.

logical operators
& | or! Non-^ XOR && short circuit with | | Short Circuit or

Bitwise operators: direct manipulation of bits.

& (with)6 & 3 = 2      0000 0110         can treat 1 as true  &  0000 0011        0 as false-- ----------------     0000 0010        2|  (OR)      Consistent with on ^ (XOR)    and on the same  rule: if the operand A is consecutive or the same operand two times, then the result is the operand a~ (take the inverse)    binary take the inverse  = 8

Shift operators:

<<  (left shift)        rule: A number of operands to the left is multiplied by 2 n >>  (right)        an operand is moved to the right, if the operand is a positive number , then the left vacant bit uses 0 complement, and vice versa. >>> (unsigned Right shift) is   uniformly used 0 to complement either positive or negative.

Ternary operator: Boolean expression-value 1: value 2;

Basic operators, remainder, logical operators, logical operators, bitwise operators, shift operators in Java

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.