day03--循环流程--while循环
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.inmind.while04;
|
||||
/*
|
||||
循环三要素:循环变量初始化、循环条件、修改循环变量
|
||||
|
||||
循环变量初始化①
|
||||
while(循环条件②){
|
||||
循环体③
|
||||
修改循环变量④
|
||||
}
|
||||
|
||||
顺序:①②③④>②③④>②③④…②不满足为止。
|
||||
*/
|
||||
public class Demo07 {
|
||||
public static void main(String[] args) {
|
||||
//打印1~10
|
||||
int i = 1;
|
||||
while(i<=10){
|
||||
System.out.println(i);
|
||||
i++;
|
||||
}
|
||||
System.out.println("------------------");
|
||||
//打印10~1
|
||||
int j = 10;
|
||||
while (j >= 1) {
|
||||
System.out.println(j);
|
||||
j--;
|
||||
}
|
||||
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