Break, Continue, return difference

Source: Internet
Author: User

1) break jumps directly out of the current loop, executes from outside the current loop, ignoring any other statements and loop condition tests in the loop body. He can only jump out of a loop, if your loop is nested loops, then you need to follow the hierarchy of your nesting, gradually using break to jump out.

2) Continue is also the end of the current cycle, but he does not jump out of the loop, but continue to judge the loop condition execution statement. He can only end a process in the loop, but cannot terminate the loop to continue.

3) The return statement can be used to return the executing branch program to the calling method.

Break, Continue, return difference

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.