天天看點

Java while語句

/*

while循環有一個标準格式,還有一個擴充格式。

标準格式:

while (條件判斷) {

循環體

}

擴充格式:

初始化語句;

循環體;

步進語句;

*/

public class Demo10While {

public static void main(String[] args) {

for (int i = 1; i <= 10; i++) {

System.out.println("我錯啦!" + i);

System.out.println("=================");

int i = 1; // 1. 初始化語句

while (i <= 10) { // 2. 條件判斷

System.out.println("我錯啦!" + i); // 3. 循環體

i++; // 4. 步進語句