day03-循环流程--while循环
This commit is contained in:
36
day03/src/com/inmind/while04/Demo07.java
Normal file
36
day03/src/com/inmind/while04/Demo07.java
Normal 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("程序结束");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user