关联语法
int
while
if
continue
public class demo2 {
public static void main(String[] args) {
int n = 0;
//进入循环
while (n <= 10) {
//条件设置
if (n % 2 == 1) {
//动作 不管是否成立
n++;
continue;
}
//不成立的时候
System.out.println(n);
//收尾 下次循环之前的动作,用作与if限定的n的值的变化
n++;
}
}
}
结果
0
2
4
6
8
10
Process finished with exit code 0