Break,continue in Java about the use of tags (reproduced)

Source: Internet
Author: User

Java's control loop structure is no keyword goto, this practice has its advantages, it improves the readability of program flow control, but there are bad places, it reduces the flexibility of program flow control, so said, "God is fair." So, Java to compensate for this shortcoming, Java provides the tag usage of break and continue. The label in Java is an identifier that follows the ":" character. Unlike other languages, the Java language label must be placed in front of the loop to be useful. Here's a look at some examples:

Break

Execution Result:

From the execution results we see that when J equals 4, "break outer" is executed, which is a break that directly ends the outer corresponding external loop, not the one in which the break is located.

Continue

The results of the implementation are as follows:

From the result we can see that J equals 4 when it is never executed. Because, when J equals 4 o'clock, "continue outer" ends the cycle of the outer loop, goes directly to the next loop, and the inner loop is no longer executed.

Source Address: http://blog.csdn.net/mdx20072419/article/details/41823949

Break,continue in Java about the use of tags (reproduced)

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.