break和continue
package 流程控制;
import javax.swing.*;
public class break和continue {//break用于在任何循环语句中,用于终止某次循环过程,不执行循环中剩余语句
//continue语句用在循环语句中终止某次循环,即跳过循环中未执行的语句,重新进行下一次是否执行循环语句
public static void main(String[] args) {
int i = 0;
while (i<=100){
if (i==20){
break;
}else{
i++;
System.out.println(i);
}
}
System.out.println("=====================");
int i1 = 0;
while (i1<=100){
if (i1%2==0){
i1++;
continue;
}else{if (i1<49){
System.out.print(i1+" ");
i1++;
}
else if(i1>50){
System.out.print(i1+" ");
i1++;
}
else if (i1==49){
System.out.println(i1+" ");
i1++;
}
}
}
}
}