Java Fundamentals Review II: Operators, keyboard entry, flow control statements, if statements, ternary operations

Source: Internet
Author: User
Tags logical operators

1. Operators

1.1, arithmetic operator + ( addition has three usages: addition, plus, String connector )-*/% + +--

1.1.1,/is the pickup,% is the surplus

Usage of 1.1.2, + + and--(A: function is self-increment, self-subtraction)

B: used alone: in front and back

C: Participate in operation using:

put in front is to increment or subtract first, then participate in the Operation

int A=10;int b=++a;-----------b=11

In the back is the first to participate in the operation, and then self-increase or reduce

int A=10;int b=a++; ----------b=10

1.2, assignment operator (=,+=,-=,*=,/=,%=) = is the most basic assignment operator int x=10; assigns 10 to X;

Knowledge Points:+=,-=,*=,/=,%= Implicit automatic casts

such as: Short S=1; s=s+1; Error, because the int to short needs a strong turn

Short s1=1;s1+=1;//Auto-strong ( implied ) ===== (short) (s1+1)

1.3. Comparison operator (= = = > < >= <=) The result is a Boolean

1.4. Logical Operators (& |  ^   ! && | | The expression used to concatenate the result is Boolean

int a=10;
int b=20;
int c=30;

Conclusion:& logic and: there is false and false, only true if it is full.

| Logical OR: TRUE if True

^ Logical XOR is the same as false, different true, couple relationship.

! False if not true, true if not false.

&& False is true only if it is true: only it will short-circuit if the previous condition is not satisfied, the latter one will not execute at all

|| Logical OR: There is true if true, except that it will short-circuit if the previous one is true and the latter one will not execute at all.

1.5, bitwise operations (>> << >>> <<<< ^ | &)

^ One data for another data bit XOR or two times, the number does not change as 2^5^5===2

--To be continued

Java Fundamentals Review II: Operators, keyboard entry, flow control statements, if statements, ternary operations

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.