Java Fundamentals (Chapter six)

Source: Internet
Author: User

Java Fundamentals (Chapter six)

One, for the use of the cycle of the occasion

L While loop--First judge, recycle

While (1, conditional expression ) {

//2 , cyclic operation

//3 , changing the loop condition expression

}

L do...while--Cycle First, then judge

do{

//2 , cyclic operation

//3 , changing the loop condition expression

}while (1. Conditional Expressions );

The above 2 cycles, generally used in the case of uncertain cycle times

Number of known cycles, preferred for loop

Ii. syntax for A For loop

For (1. Initial Part  ; 2. condition judgment ; 3. Iteration Section ) {

4. cyclic operation

}

Iii. order of execution for a For loop

Section 1 Secondary Cycle

L Perform the initial part first ( only executed at 1 cycles )

L re-judge the condition.

N If the condition is met, the loop operation is performed

N If the condition is not met, the loop ends

Section 2~n sub-cycle-condition Satisfaction

After the 1th time the loop operation is completed

Perform the Iteration section first

And then the condition is judged.

If the condition is met, the loop operation is performed

If the condition is not met, the loop ends

Four, 2 keywords

L Break " General and if conditional statements are used together "

To end a switch statement in a switch statement

To end or terminate a loop in a loop structure

L Continue

In the loop, end the loop and go to the next loop.

Java Fundamentals (Chapter six)

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.