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 <<