38 java 使用标签跳出多层嵌套循环

public class Interview {
    public static void main(String[] args) {
        //使用带标签的break跳出多层嵌套循环
        Boolean flag = true;

        int count = 0;
        loop:while (flag){
            for(int i=0;i<1000;i++){

                for(int j =0;i<1000;j++){
                    count++;
                    if(count>10){
                       break loop;// continue loop;
                    }
                    System.out.println(count);
                }

            }
        }
        System.out.println("test");
    }
}

 

posted @ 2017-03-30 15:21  life_start  阅读(221)  评论(0编辑  收藏  举报