/**
* 简单的while,do...while语句
*/
public class TestWhile {
public static void main(String[] args) {
// TODO Auto-generated method stub
int i = 0; // 定义一个Int类型的变量i,初始赋值为0
while (i < 10) { //执行while循环语句
System.out.print(i);
i++;
}
i = 0; // 定义一个Int类型的变量i,初始赋值为0
do { //执行灰....while循环语句
System.out.print(i);
i++;
} while (i < 10);
}
}
本文通过Java代码展示了while和do...while循环的基本用法。在示例中,两种循环都被用来打印从0到9的整数,清晰地展示了这两种循环的区别及如何使用。
1488

被折叠的 条评论
为什么被折叠?



