Summary of Java operators and process controls

Source: Internet
Author: User

First,the Java operator summary :

1. Arithmetic operators:

① Single:+(take positive),-(negative), + +(since 1), -- (self-reduction 1 );

② Binocular:+-*/%(remainder) (+ can also connect strings);

③ Three mesh:a>b?true:false

Description: true(that is, the value before the colon) when a is greater than b , false otherwise This entire operator includes a relational operator (can be ">""< " "! =" and so on), one "? ", a": ", you need to have two expressions or a value or an object before and after a colon.

2. Bitwise operators:(convert to binary before operation )

① and (&), non-(~), or (| ), XOR, or ( ^ );

② shift operators:<<(signed left),>>(signed right shift), >>> (unsigned right shift);

③ left shift 1 2 1 2

3. Comparison operators:= =,<,>,<=,>= ,!=

①= = vs . = Compare the base data type is the comparison value, the comparison reference type is the virtual address;

② can only compare basic data types except = = and ! =.

4. logical operators: An expression that is used to connect two boolean types.

&& (double and), || (dual or), & (with), | (or), ^ (XOR), ! (non-op)

Note: ① && & & && false false

②| | | | | | true true

③&& | | can be understood as a physical short circuit. , multi-use in practice && and || .

Second,Java Process Control Summary :

1. Branch Statements:

① Conditional Statement- if

Conditional Statement - if... Else ... ..

Conditional Statement - if... else if ... ..

② Conditional Statement- Switch-case

Switch ( expression )

{

Case Value 1: statement block 1

...

Case value n: statement block N

Default: statement block n+1

}

Description: The value of ① expression can only accept int byte , char , short jdk1.6 after string can also, do not accept other types of values, do not allow duplicate case value.

②Switch once it encounters the first case match, the program jumps to the tab location and starts executing all of the program code in a sequential sequence, regardless of the case behind it Condition matches until a break statement is encountered .

2. Looping statements:

① Loop Statement- while

while ( conditional expression )

{

Executes the statement block;

}

② Loop Statement- do... while (at least one loop is executed)

Do

{

Executes the statement block;

} while ( conditional expression );

③ Loop Statement- for

For ( initialization expression; cyclic conditional expression; post-loop action expression )

{

EXECUTE statement block

}

3. Loop Interrupt Statement -break ,continue:

when you use a loop statement, you can end the loop only if the value of the loop condition expression is false . Sometimes we want to interrupt the loop prematurely, and to do this, you simply add a break or continue statement to the LOOP statement block .

① Interrupt Statement- break

The break statement is used to terminate execution of a block of statements. Used in the Loop statement body, you can forcibly exit the loop.

"Break; "statement: can appear in while , Do ... .. while , for , Switch the body of the statement.

Breaklabelstatement: can appear in any body of the statement. The majority is still used in the loop.

② Interrupt Statement- continue

The continue statement is used in the Loop statement body to terminate a looping process, skipping a loop that is not executed under the Continue statement in the loop body, and starting the next cycle.

"continue; "statement: can only appear in a loop statement while , Do ... .. while , for the.

Summary of Java operators and process controls

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.