Hanshunping the No. 04 step of the Java Process Control

Source: Internet
Author: User

4.1 Java Basic syntax-three large flow control 4.1.1 Sequential control 4.1.2 Branch control

Single Branch

IF (conditional expression)

{

Statement

}

Dual Branch

IF (conditional expression)

{

Statement

}else

{

Statement

}

Multi-Branch

V method 1:

IF (conditional expression)

{

Statement

}else if (conditional expression)

{

Statement

}else

{

Statement

}

V method 2:

switch (conditional expression)

{

CASE constant 1:

Statement 1;

Break

Case constant 2:

Statement 2;

Break

...

CASE Constant N:

Statement N;

Break

Default

Statement

}

Note: The data type of the resulting result of the conditional expression should be the same as the type of the constant following the case.

The main data types available in switch are: Allow Byte,short,int,char,enum (enumeration), and so on.

4.1.3 Cycle Control

1. for Loops

2. while Loops

while (loop condition)

{

Statement Loop body

}

Description: The while loop is the first to judge the execution of the statement.

3. Do While Loops

Do

{

Statement Loop body

}while (cyclic conditions);

Description: The Do While loop is executed first and then judged.

Hanshunping Programming Tips :

    • Take a complex problem and disassemble it into a simple question.
    • How to die? Method: First fixed some values to implement the function, and then consider how to change the fixed value to a variable value.
    • Cycle, pay attention to find the law.

Hanshunping the No. 04 step of the Java Process Control

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.