day03-.for循环的语法&练习
This commit is contained in:
35
day03/src/com/inmind/Demo03_for.java
Normal file
35
day03/src/com/inmind/Demo03_for.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package com.inmind;
|
||||||
|
/*
|
||||||
|
for,while,do-while 循环
|
||||||
|
循环三要素:循环变量初始化、循环条件、修改循环变量
|
||||||
|
|
||||||
|
for循环的格式:
|
||||||
|
for(循环变量初始化①;循环条件②;修改循环变量④){
|
||||||
|
循环体语句③;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
执行顺序:①②③④>②③④>②③④…②不满足为止。
|
||||||
|
*/
|
||||||
|
public class Demo03_for {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
/*
|
||||||
|
打印1~10的值
|
||||||
|
打印10~1的值
|
||||||
|
打印所有的字母a-z、A-Z
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
//for循环的语法学习
|
||||||
|
public static void forMethod() {
|
||||||
|
//去跑圈,要求你跑1000圈
|
||||||
|
/*System.out.println("第1圈");
|
||||||
|
System.out.println("第2圈");
|
||||||
|
System.out.println("第3圈");*/
|
||||||
|
|
||||||
|
for(int i = 1;i<=3;i++){
|
||||||
|
System.out.println("第"+i+"圈");
|
||||||
|
}
|
||||||
|
System.out.println("程序结束");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user