day03--循环的控制-continue关键字

This commit is contained in:
2026-09-17 11:45:53 +08:00
parent d1e15efe98
commit a9f89feb98
2 changed files with 21 additions and 1 deletions
@@ -6,7 +6,7 @@ break的作用:
中断switch
*/
public class Demo09 {
public class BreakDemo09 {
public static void main(String[] args) {
/*int a = 4;
if (a == 4) {
@@ -0,0 +1,20 @@
package com.inmind.controller05;
import com.sun.source.tree.IfTree;
/*
循环控制_continue
continue的作用:跳过本次循环体,继续下一次循环
*/
public class ContinueDemo10 {
public static void main(String[] args) {
//遇到第4圈,不跑,(不执行循环体),直接跑5圈(执行第5次循环体)
for (int i = 1; i < 11; i++) {
//判断是否是4
if (i == 4) {
continue;//直接结束本次循环,Continue关键字下方的代码在本次循环中就不执行了
}
System.out.println(i);
}
}
}