Java Series Learning (iv)-Calculation of operations

Source: Internet
Author: User
Tags bitwise logical operators

1. Operators

(1) Arithmetic operators

a:+,-,*,/,%,++,--

The use of b:+

"A. Addition"

"B. Plus"

"C. String Connection Payment"

The difference between c:/and%

"When the data is division, the quotient is taken, and the remainder is taken."

The use of d:++ and--

"A. When used alone: put in front and back of the operating data the effect is the same, a++ or ++a effect is the same"

"B. Participate in operation Operations-put in front of operand: increment or decrement first, then participate in operation"

"C. Participate in the operation of operations-placed after the operand: first participate in the operation, and then self-increment or decrement"

(2) Assignment operator

a:=,+=,*=,/=,%=

B: = is called an assignment operator

C: Features of the extended assignment operator

(3) Comparison operators

a:==,!=,>,>=,<,<=

B: The end result is a Boolean type, regardless of the operator's ends

C: Don't write = =

(4) Logical operators

a:&&,| |,!

"&&: The result is the same as the &, except that it has a short-circuit effect. The left side is false and the right side does not execute "

"| | : Results and | is the same, but there is a short-circuit effect. The left is true and the right side does not execute "

"!: Not true false, not false true"

B: Logical operators are used to concatenate Boolean types

(5) Bitwise operator

A: To do a bitwise operation, the first thing to do is to convert the data into binary

b:&,|,^,~

"&: false, False"

"|: Has true, then true"

"^: Bitwise XOR OR operation, same as false, difference true"

"~: Bitwise inverse Operator: 0 change to 0"

C:<<,>>,>>

"<<: Left left highest bit discarded, right 0"

">>: Right shift the highest bit is 0, the left side is 0; the highest bit is 1, the left side is 1"

(6) Ternary operator

A: Format

"Comparison expression? Expression 1: Expression 2"

B: Execution Process

"The value of the comparison expression is evaluated first, and if true, the expression 1 is executed, otherwise the expression 2"

2. Keyboard entry

3. Process Control Statements

(1) Order results from top to bottom, executed sequentially

(2) Select structure to execute different codes according to different choices

(3) Loop structure to do some repetitive code

Java Series Learning (iv)-Calculation of operations

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.