Java Learning while loop

Source: Internet
Author: User

Learn to program Java Learning while the loop is published, welcome to visit through Xuebiancheng8.com

The previous analysis of Java's Process control is divided into select structure, loop structure, wherein the loop structure is divided into while,do...while and for loop

Below to analyze the while loop in the next loop structure

Why should there be a while loop in Java? Let's look at an example.

What do I do now to perform 10,000 i++ operations?

To do this, we have to do a 10,000-line i++ operation. This wastes a lot of time. This time you can use the Loop statement to implement, as long as a few simple lines of code.

while (i<=10000) {

System.out.println (i);

i++;

}

The above example is the while loop, which can help us print 10,000 times the value of I and perform 10,000 i++ operations.

below to analyze the syntax of the next while

while (condition) {

Cyclic operation;

}

The loop operation is performed when the condition is satisfied, that is, when the value of the condition is true.

While loop is characterized by first judgment and execution, when the condition is not established, the loop may not be executed once.

When the loop is not fixed, it is recommended to use a for loop when the number of loops is fixed.

Please visit xuebiancheng8.com for details. The specific URL is

Http://xuebiancheng8.com/play/goodgoodstudy_59_daydayup.html


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.