JavaSE review diary: cyclic termination Statement (break/break outerFor/continue), javaseouterfor

Source: Internet
Author: User

JavaSE review diary: cyclic termination Statement (break/break outerFor/continue), javaseouterfor

I have no network recently, but I have collected my blog for a few days. This time I caught the opportunity to post my blog and started with three articles;




/** Cyclic termination statement: break/break outerFor/continue * // ** break statement * 1. used to end the branch statement in the switch statement. * 2. the break can also be used in a loop. By default, the first loop closest to the break is ended. * break: the end loop. * return: the end method and a value are returned; * // * public class JavaSE {public static void main (String [] args) {for (int I = 0; I <10; ++ I) {System. out. println (I); if (I = 5) {break; // when I is equal to 5, the loop ends and the loop ends.} System. out. println ("output after the break end loop");} * // else/** break outerFor statement * terminate the specified loop; * // * public class JavaSE {public static void main (String [] args) {// for (int I = 0; I <10; ++ I) {// System. out. println (I); // if (I = 5) {// break; // terminate the recent loop //} // System. out. println (I); // I is a local variable of the for loop. It can only be used in the for loop and cannot be called outside. Therefore, the following error is reported: The symbol outerFor cannot be found: for (int I = 0; I <10; ++ I) {for (int j = 0; j <I; ++ j) {System. out. println (j + ""); if (I = 3) {// when I = 3, the outer loop ends, and the inner loop continues break outerFor ;}}}}} * // The continue/** continue statement * only terminates the current loop, but does not affect the subsequent loop. */public class JavaSE {public static void main (String [] args) {for (int I = 0; I <10; ++ I) {if (I = 3) {continue; // do not loop when I = 3, however, the output will not be affected after 4-9} System. out. println (I );}}}

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Jie, I want to educate WWW. JAOVO. COM <<

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.