java-Process Control Statements

Source: Internet
Author: User
Tags case statement

If of a Java conditional statement

Note: If the IF condition is set when the execution statement is only one, it is possible to omit the curly brace drop! But if there are multiple execution statements, then curly braces are indispensable.

The if...else of the Java conditional statement

The multiple if of a Java conditional statement

Nested if of a Java conditional statement

Switch of the Java conditional statement

Execution procedure: When the value of the expression after switch is the same as the value after the case statement, it starts down from that position until the break statement is encountered or the switch statement block ends, and the code of the default block is executed if there is no matching case statement.

The while of the Java Loop statement

Execution process:

< 1 >, determine if the condition behind the while is established (True/false)

< 2 >, when the condition is established, execute the operation code within the loop, then repeat < 1 >, < 2, until the loop condition is not established

Features: first judgment, after execution

The do...while of the Java Loop statement

Execution process:

<1>, perform the cycle operation first, and then determine if the loop condition is true

<2>, if the conditions are established, continue to implement < 1 >, < 2, until the cycle conditions are not established

Features: First execution, after judgment

Thus, the Do...while statement guarantees that the loop is executed at least once!

The Java Loop statement for

Execution process:

<1>, executes the loop variable initialization section, sets the initial state of the loop, which executes only once in the entire loop

<2>, the judgment of the cyclic condition, if the condition is true, the loop body code is executed, and if False, the loop is exited directly

<3>, execute cyclic variable change part, change the value of the loop variable, in order to make the next condition judgment

<4>, re-execute < 2 >, < 3 >, < 4, until Exit loop

Features: simpler and easier to read than the while and DO...WHILE statement structure

Break of the Java loop jump statement

Use the break statement to exit the specified loop and execute the code immediately following the loop.

The continue of the Java loop jump statement

The function of continue is to skip the remaining statements in the loop body to perform the next loop

java-Process Control Statements

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.