2016.1.19 Learning Summary (while, do/while, break, continue)

Source: Internet
Author: User

What is a cyclic structure? What are the elements?

Loop structure refers to code that can be executed repeatedly

Elements: 1, keywords, 2, to be repeatedly executed code; 3, Loop end condition.

What are the loop statements that can be implemented? What types can be divided into?

1, while 2, Do/while 3, for

Prior loop (while), posterior loop (do/while)

What does the while loop need to be aware of?

While loops can be executed 0 or more times. If the condition in the start part of the loop is not true, the loop code can never be executed.

How do I count the number of cyclic executions?

An integer variable is declared outside the recirculation body and initialized to 0;

In the loop, the increment of the variable is calculated, and the end result is the number of cycles.

What is the execution process of the Do/while statement?

Do/while can be executed 1 or more times. The loop code executes at least once, regardless of whether the condition of the judgment part behind the loop is true, and then determines whether the condition of the continuation loop is met.

What do I need to be aware of when do/while statements are used?

Do is a Java keyword and must be used in conjunction with while;

The Do/while loop is started by do and ends with a while: it must be: the ";" After the second while (expression) cannot be lost, he represents the end of the Do/while statement;

The expression in parentheses after the while is used for conditional judgment and determines whether the loop body executes;

The loop body after do can be a statement that executes, and a compound statement that can consist of multiple statements.

What is the difference between a break statement and a continue statement?

The break statement executes the end of the entire module, continue statement execution ends with the statement before continue in the module, followed by a statement exclusion.

2016.1.19 Learning Summary (while, do/while, break, continue)

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.