当前位置:编程学习 > JAVA >>

标号Label的使用

char a; 
       outer: 
       for(int i=0;i<3;i++){ 
           for(int j=0;j<3;j++){ 
               a = (char)System.in.read(); 
               System.in.read();   //再读一个换行符  
               System.in.read();   //再读一个回车符  
               if(a=='b'){ 
                   break outer; 
               } 
               if(a == 'c'){ 
                   continue outer; 
               } 
               System.out.println("内部循环中!"); 
           } 
           System.out.println("外部循环中!"); 
       } 
 char a;
        outer:
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                a = (char)System.in.read();
                System.in.read();   //再读一个换行符
                System.in.read();   //再读一个回车符
                if(a=='b'){
                    break outer;
                }
                if(a == 'c'){
                    continue outer;
                }
                System.out.println("内部循环中!");
            }
            System.out.println("外部循环中!");
        }

 break outer 就是跳出所有的循环.

contiue outer 就是接着执行下一个outer循环

  \

摘自  张仁阳专栏 

补充:软件开发 , Java ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,