Java-preliminary Understanding-Chapter III-Practice of statement-for

Source: Internet
Author: User

I. Using the FOR statement to complete the summation

The For statement is similar to the while statement and can be used as an additive algorithm

For and while statements, there is a small difference between the two, the local variable control range is different.

If the initial variable is used to control the loop, then using for is more efficient than the while and can free the unused local variables.

Two. Infinite loops

In the late development, the infinite loop is applied. The programmer can sometimes not determine the number of cycles, and in the loop, it may produce unlimited operations.

For the intermediate expression is not written, the default is true.

It's strange that we've had a discussion before about simply writing a Boolean data, which seems to work .

Note: Today, when you write again, DOS can be compiled and executed, the previous program is not written wrong?

Strange, How is System.out.println ("over!"); What about mistakes?

We put down the error of the output statement, first look at while the condition of the statement can be recognized directly input true data, the display is can, but no control of the number of cycles, operations can be manipulated. To look back at the error of the output statement is that you cannot execute to the output statement, which is always in the loop.

Java-preliminary Understanding-Chapter III-Practice of statement-for

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.