第一结束本次循环
public class Test3{
public static void main(String[] args){
for(int i=1;i<=9;i++){
for(int j=1;j<=i;j++){
System.out.print(i+"--"+j);
if(i==2 && j==1)
break;
}
System.out.println();
}
}
}
第二嵌套的每一层都结束循环
public class Test3{
public static void main(String[] args){
flag:for(int i=1;i<=9;i++){
for(int j=1;j<=9;j++){
System.out.print(i+"--"+j);
if(i==2 && j==3)
break flag;
}
System.out.println();
}
}
}