基础语法-循环结构while

            基础语法-循环结构while

                                       作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

 

 

 

一.while语句格式

while(条件表达式){
  执行语句;  
}

二.while语句案例

/**
 *     while案例
 * @author 尹正杰
 *
 */
public class WhileDome01 {

    public static void main(String[] args) {
        
            /*
             *     打印1-20之间的所有奇数
             */
            int x = 1;
            
            while (x < 20) {
                System.out.println(x);
                x += 2;
            }
    }

}

原文地址:https://www.cnblogs.com/yinzhengjie2020/p/12214214.html