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");
    }
}

输出结果为:

 






 

posted @ 2013-07-10 10:42  jlins  阅读(154)  评论(0)    收藏  举报