day03-循环控制语句--死循环

This commit is contained in:
2026-01-16 13:44:29 +08:00
parent 88be1d6dcc
commit 15e5e511e0

View File

@@ -0,0 +1,27 @@
package com.inmind.circle_control07;
/*
死循环:循环条件永远满足
*/
public class Demo14 {
public static void main(String[] args) {
//while 死循环 :最常用的死循环
while (true) {
System.out.println(1);
//在死循环中可以使用break在满足某种条件下结束循环
}
//---------------------------------------
//for 死循环
/*for (; ; ) {
System.out.println(1);
}
*/
//---------------------------
//do-while 死循环
/*do {
System.out.println(1);
} while (true);*/
// System.out.println("程序结束");
}
}