-
while循环
//while循环,是一个无限循环
//定义一个变量
int x = 1;
//当x小于5 是,则打印,并且x +1
while (x < 5) {
System.out.println(x++);
}
-
for循环
//for 循环
for (int i = 0; i < 5; i++) {
System.out.println(i);
}
-
do.while循环,死循环(一般很少使用)
int x = 3;
do{
System.out.println("3");
}while (x == 3);
网友评论