day03-循环流程--while循环

This commit is contained in:
2026-07-16 16:06:32 +08:00
parent 95c80e4646
commit 60b4a56f6b

View File

@@ -0,0 +1,36 @@
package com.inmind.while04;
/*
循环变量初始化①
while(循环条件②){
循环体③
修改循环变量④
}
顺序:①②③④>②③④>②③④…②不满足为止。
*/
public class Demo07 {
public static void main(String[] args) {
//打印1~10的值
int j = 1;
while(j<=10){
System.out.println(j);
j++;
}
System.out.println("-----------------------");
//打印10~1的值
int k = 10;
while (k >= 1) {
System.out.println(k);
k--;
}
System.out.println("-----------------------");
//打印A~Z的值
char c = 'A';
while (c <= 'Z') {
System.out.println(c);
c++;
}
System.out.println("程序结束");
}
}