|NO.Z.00074|——————————|BigDataEnd|——|Java&循环结构.V13|——|Java.v13|while循环.v01|概念编程|

一、while循环概念
### --- while循环逻辑结构

while(条件表达式) {
    循环体;
}
### --- while循环

~~~     ——>    判断条件表达式是否成立
~~~     ——>    => 若成立,则执行循环体=> 判断条件表达式是否成立
~~~     ——>    => 若不成立,则循环结束
二、while循环结构
三、编程代码
### --- 编程代码

/*
    编程实现while循环的使用
 */
public class WhileTest {
    
    public static void main(String[] args) {
        
        // 1.使用for循环打印1 ~ 10之间的所有整数
        // 在()或{}中声明的变量叫做块变量,作用范围是从声明开始一直到语句块结束
        for(int i = 1; i <= 10; i++) {
            System.out.println("i = " + i);
        }
        
        System.out.println("-----------------------------");
        // 2.使用while循环打印1 ~ 10之间的所有整数
        int i = 1;
        while(i <= 10) {
            System.out.println("i = " + i);
            i++;
        }
    }
}
四、编译打印
### --- 编译

C:\Users\Administrator\Desktop\project>javac WhileTest.java
### --- 打印输出

C:\Users\Administrator\Desktop\project>java WhileTest
i = 1
i = 2
i = 3
i = 4
i = 5
i = 6
i = 7
i = 8
i = 9
i = 10
-----------------------------
i = 1
i = 2
i = 3
i = 4
i = 5
i = 6
i = 7
i = 8
i = 9
i = 10

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(7)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示