Java Control statements-break and continue, javabreakcontinue

Source: Internet
Author: User

Java Control statements-break and continue, javabreakcontinue

In the main part of any loop statement, break can be used to control the loop process.

  • BreakIt is used to forcibly exit the loop without executing the remaining statements in the loop. (The break statement can also be used in multiple switch statements)
  • ContinueThe statement is used in the loop body to terminate a loop process, that is, to skip the statements that have not been executed in the loop body, and then determine whether to execute the next loop.

[Break example]: generate a random number ranging from 0 to until 88 is generated. Stop the loop!

[Example of continue]: // outputs The number between and that cannot be divisible by 3.

Related Article

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.