S1/using Java to understand program logic/06-loop Structure (ii)

Source: Internet
Author: User

Four parts of the loop structure:

(1) Initial part: Set the initial state of the loop

(2) loop body: Repeated execution of code

(3) Iteration part: the part to be executed before the next cycle begins

(4) Cycle conditions: Determine whether to continue the cycle of conditions

For ( expression 1; expression 2; expression 3) {

Loop Body

}

for looping structure 3 meaning of the expression

An expression

Form

Function

Example

Expression 1

Assignment statements

The initial part of the loop structure, assigning the initial value to the loop variable

int i=0

Expression 2

Conditional statements

Cyclic condition of cyclic condition loop structure of cyclic structure

i<100

Expression 3

Assignment statements, usually using the + + or -- operator

The iterative part of a looping structure, usually used to modify the value of a loop variable

i++

Java supports 3 types of jumps: Break,continue, and return.

Break is used to terminate a loop so that the program jumps to the next statement outside the loop body. Statements that are in a loop after a break are no longer executed, and the loop also stops executing.

The difference between break and continue , in the loop structure:

The break statement is used to terminate a loop in which the program jumps to the next statement outside the loop body.

The Continue statement is a statement used to jump out of this loop and into the next loop.

Java's most basic three loop structures, while, Do-while, and for loop structures.

S1/using Java to understand program logic/06-loop Structure (ii)

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.