一、continue结束本次循环,进入下次循环
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
if(j == 3) continue;
System.out.print("(" + i + "," + j +")");
}
System.out.println();
}
二、break
1、break终止本次循环
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
if(j == 3) break;
System.out.print("(" + i + "," + j +")");
}
System.out.println();
}
2、break加标号退出循环
flag://设置标号,退出循环
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
if(j == 3) break flag;
System.out.print("(" + i + "," + j +")");
}
System.out.println();
}
三、return退出循环
//return
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
if(j == 3) return;
System.out.print("(" + i + "," + j +")");
}
System.out.println();
}