使用continue忽略本次循环中剩下的语句
1 public class Test 2 { 3 4 public static void main(String[] args) 5 { 6 for(int i=0;i<10;i++) 7 { 8 if(i==5) 9 { 10 continue; 11 } 12 //当i==5时,下面语句不再被执行,然后继续下一次循环 13 System.out.println("hello"); 14 System.out.println("小明"); 15 } 16 } 17 }

浙公网安备 33010602011771号