|NO.Z.00078|——————————|BigDataEnd|——|Java&循环结构.V17|——|Java.v17|dowhile循环.v01|概念编程|

一、dowhile循环概念使用
### --- dowhile循环语法结构

do {
    循环体;
} while(条件表达式);
二、dowhile循环结构
### --- dowhile循环结构

~~~     ——>        执行循环体=> 判断条件表达式是否成立
~~~     ——>        => 若成立,则执行循环体=> 判断条件表达式是否成立
~~~     ——>        => 若不成立,则循环结束
三、dowhile循环执行流程
四、dowhile循环编程代码
### --- 案例题目

~~~     ——>    do-while循环主要用于至少执行一次循环体的场合中
五、编程代码
### --- 编程代码

/*
    编程实现do while循环的使用
 */
public class DoWhileTest {
    
    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;
        int i = 11;
        while(i <= 10) {
            System.out.println("i = " + i);
            i++;
        }
        
        System.out.println("-----------------------------");
        // 使用do while循环打印1 ~ 10之间的所有整数
        //i = 1;
        i = 11;
        do {
            System.out.println("i = " + i);
            i++;
        } while(i <= 10);
        
        
    }
}
六、编译打印
### --- 编译

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

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

 
 
 
 
 
 
 
 
 

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  阅读(18)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 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

导航

统计

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