导入java.util.*;
导入java.io.*;
主类{
public static void main(String[] args) {
int a=0;
同时(a++<4) {
System.out.println("检查");
}
}
}
这里我们得到结果 查看 查看 查看 检查
但我有一个疑问是
In the while loop there is no update statement to execute to loop repeatedly
我认为答案只是 1 次“检查”。但是当我执行代码时,它显示 4 次“检查”。
我不是it学生。所以请给我解释清楚理解。
while 循环仅适用于条件(真/假)。und 必须像 while(a<4) and not like while(a++<4) your code must bei like this
while(a<4) {
System.out.println("Check");
a++;
}
语法 while 循环与 for 循环不同
for (int a=0;a<4;a++)
同时
while(a<4) {
a++;
}