for
package util.demo;
public class Test01 {
public static void main(String[] arg){
//循环 for
for(int i=0;i<5;i++){
System.out.println("我是输出第"+(i+1)+"行");
}
}
}
while\do…while
package util.demo;
public class Test01 {
public static void main(String[] arg) {
int a = 3;
while (a > 0) {
System.out.println("当前a的值:" + a);
a--;
}
int b = 10;
do {
System.out.println("当前b的值:" + b);
b--;
} while (b > 0);
}
}