Java control Statements--break and continue

Source: Internet
Author: User

In the body part of any loop statement, a break is used to control the flow of the loop.

  • break is used to forcibly exit the loop without executing the remaining statements in the loop. (Break statement can also be used in multiple statement switch)
  • The continue statement is used in the loop statement body to terminate a looping process , which skips a statement that has not yet been executed in the loop body, and then performs the next execution of the loop decision.

Example of break: Generates a random number of 0-100 until 88 is generated, stopping the loop!

"Continue example"://The number output that cannot be divisible by 3 between 100-150

Java control Statements--break and continue

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.