while循环
while(条件测试){
do...
}
1.只要条件测试为true就运行do
2.条件测试(conditional test)的结果不是true就是false。
注:条件测试不能为x=10一类语句。
eg:
public class MyFirstApp{
public static void main(String[] args){
int x=1;
System.out.println("Before the Loop");
while(x<4){
System.out.println("In the Loop");
x=x+1;
}
System.out.println("This is after the Loop");
}
}
输出结果为:

浙公网安备 33010602011771号