1、while循环
先判断再执行:
public static void main(String[] args){
int x = 0;
while( x < 3 ) {
System.out.println("value of x : " + x );
x++;
}
}
结果:
2、do while循环
先执行在判断,至少执行一次。
public static void main(String[] args){
int x = 0;
while( x < 3 ) {
System.out.println("value of x : " + x );
x++;
}
}
结果: