Java Basics Essay 2

Source: Internet
Author: User
Tags arithmetic operators

Various operators: Arithmetic operators:: +,-,*,/,%,++,--

+ +: self-increment

--: self-reduction

When used alone, + + or--whether placed in front of the variable or behind it, the result is the same.

When participating in the operation:

If + + or--at the back of the variable, take the variable to participate in the operation, after the variable to do + + or--

If + + or--at the front of the variable, the first variable to do the + + or--, take the variable to participate in the operation

Basic assignment Operator: = Extended assignment Operator: +=,-=,*=,/=,%=

a+=10; equivalent to a = (data type of a) (A + 10);

Relational operators: ==,!=,>,>=,<,<= (the result of a relational operator isBoolean, which is either true or false ) Logical operator: a:&,|,^,! B: &&,| |

& Logic with: False if False

| Logical OR: TRUE if

^ Logical XOR: Same as false, different to true

The logical non: false is true, False if not true

What is the difference between a:&& and &?

A: The end result is the same.

The b:&& has a short circuit effect. The left side is false and the right side is not executed.

& whether the left is false or true, the right side will execute

What is the difference between b:| | and |?

A: The end result is the same

b:| | has a short circuit effect. True on the left, not on the right

| Whether the left is false or true, the right side will execute

Ternary operator: (relational expression)? Expression 1: Expression 2;

If the condition is true, the result of the operation is an expression of 1;

If the condition is false, the result of the operation is an expression of 2;

Example: int x=1,y=2,z;

z = (x>y)? x:y; Z is the largest number in X, y

Java Basics Essay 2

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.