Java continue, break, label

Source: Internet
Author: User

The body part of any iteration statement can control the looping process with break and continue, where break is used to forcibly exit the loop without executing the remaining statements in the loop.

The continue stops the current iteration and then returns to the beginning of the loop, starting the next iteration.

The label can be used to jump out of a multilayer loop, such as

 Public classTestLabel { Public Static voidMain (string[] args) {//MarkingOne : for(inti = 0; I < 3; i++) {             for(intj = 0; J < 5; J + +) {                if(J = = 3)                     BreakOne ; System.out.println ("I:" + i + "-----J:" +j); }        }    }}

The results of the implementation are as follows:

i:0-----j:0i:0-----j:1i:0-----J:2

Java continue, break, label

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.