Control statements in Java

Source: Internet
Author: User
Control Statement 1.1 sequential structure (most common)

Features: code executes from top to bottom

1.2 Selection structure:

If Judgment statement:

Switch Judgment statement:

Considerations for using the switch statement:

1. A break is required at the end of each statement to prevent the switch from penetrating.

The amount used to judge in a 2.switch statement can only be int, Short,char,byte String (only after Jdk7)

The data followed by 3.Case must be constant.

The advantages of the switch statement: The statement structure is clear, the running rate is fast.

Disadvantages of the switch statement:

If the switch can do not do, switch can do the if must be implemented.

1.3 Cycle Structure

While loop: First judge the execution

Structure:

while (loop condition) {

Loop body.

}

Do and loop: once executed, the loop body is bound to execute once.

Structure:

bo=

Circulation body;

}while (cyclic conditions);

For loop:

Structure:

for (;;) {

Loop body

}

Control statements in Java

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.