Java se break and Continue tags

Source: Internet
Author: User

Text is to learn the network of articles on the summary, thank you for your selfless sharing.

Java does not provide a goto feature, but it retains the goto keyword. In Java, you can use the break label and the continue label feature to implement the Goto feature in a simple version.

Here's a little code to make a tip.

Package se;/** * * <p> * Description: Use the TAB function of break and Continue * </p> * @author Zhangjunshuai * @version 1.0 * C                                reate date:2014-10-16 pm 4:11:39 * Project name:java7thread * * <pre> * Modification History: * Date Author Version Description *---------------------------------- -------------------------------------------------------------------------* Lastchange: $Date:: $ $Auth Or: $ $Rev: $ * </pre> * */public class Breakgoto {/** * <p> * </p> * * @author Zhang Junshuai * @date 2014-10-16 pm 3:28:53 * @param args */public static void main (string[] args) {Boolean t = True;first: {sec Ond: {//break must be in the tag, you can not jump out of the unrelated label so that no label third: {System.out.println ("before the break."); if (t) break second; Break off of second//blockSystem.out.println ("This won ' t execute");} System.out.println ("This won ' t execute");} con:for (int j = 0; J < 4; J + +) {for (iNT i = 0; I < 10; i++) {System.out.println ("---jump---" +i+j); continue con;//here is a loop that jumps out of I, jumping to the J Loop}}system.out.println ("This was after Second block. ");} No:{system.out.println ("No");}}}

Reference:

http://blog.csdn.net/jamesfancy/article/details/1198210

http://zhangkun716717-126-com.iteye.com/blog/933836

Java se break and Continue tags

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.