(3)break、continue

 1 class OtherDemo 
 2 {
 3     public static void main(String[] args) 
 4     {
 5         //break:
 6         w:for(int x=0; x<3; x++)
 7         {
 8             for(int y=0; y<4; y++)
 9             {
10                 System.out.println("x="+x);
11                 break w;
12             }                
13         }
14 
15         //continue:只能作用于循环结构。继续循环。特点:结束本次循环,继续下一次循环。
16 
17         for(int x=1; x<=10; x++)
18         {
19             if(x%2==1)
20                 continue;
21             System.out.println("x="+x);
22             
23         }
24 
25         w:for(int x=0; x<3; x++)
26         {
27             for(int y=0; y<4; y++)
28             {
29                 System.out.println("x="+x);
30                 continue w;
31             }                
32         }
33 
34         /*
35         记住:
36         1,break和continue语句作用的范围。
37         2,break和continue单独存在时,下面可以有任何语句。因为都执行不到。
38         */
39 
40 //        break;
41 //        continue;
42     }
43 }
原文地址:https://www.cnblogs.com/jx-yangbo/p/6077889.html