break 和 continue

 1 public class BreakAndContinue
 2 {
 3     public static void main(String[] args)
 4     {
 5         int i = 0;
 6         outer:
 7         while(true)
 8         {
 9             System.out.println ("Outer while loop");
10             while (true)
11             {
12                 i++;
13                 System.out.println ("i = "+ i);
14                 if (i == 1)
15                 {
16                     System.out.println("continue");
17                     continue;
18                 }
19                 if (i == 3)
20                 {
21                     System.out.println("continue outer");
22                     continue outer;
23                 }
24                 if (i == 5)
25                 {
26                     System.out.println("break");
27                     break;
28                 }
29                 if (i == 7)
30                 {
31                     System.out.println("break outer");
32                     break outer;
33                 }
34             }
35         }
36     }
37 }
38 
39     
View Code

 

posted on 2019-03-09 21:25  空谈误国-实干兴邦  阅读(104)  评论(0编辑  收藏  举报