break and continue loop control statement usage

/* break keyword The break keyword can be used in switch. Once executed, the entire switch will end immediately. The break keyword can also be used in other statements, the entire loop statement will end immediately, and the loop will be interrupted */ public class demo07{     public static void main(String[] args){         for(int i=1;i<=100;i++){             if(i==4){                 break;             }             System.out.println("Experience up: "+i);         }     } }
                                         












/*

                                         continue keyword continue keyword
immediately skips this loop and enters the next loop statement
*/
public class demo07{     public static void main(String[] args){         for(int i=1;i<=10; i++){             if(i==4){                 continue;             }             System.out.println("Experience increased: "+i);         }     }








 

Guess you like

Origin blog.csdn.net/weixin_45650003/article/details/119227319