while循环
1 /* 2 while循环有一个标准格式,还有一个扩展格式。 3 4 标准格式: 5 while (条件判断) { 6 循环体 7 } 8 9 扩展格式: 10 11 初始化语句; 12 while (条件判断) { 13 循环体; 14 步进语句; 15 } 16 */ 17 public class Demo10While { 18 public static void main(String[] args) { 19 for (int i = 1; i <= 10; i++) { 20 System.out.println("我错啦!" + i); 21 } 22 System.out.println("================="); 23 24 int i = 1; // 1. 初始化语句 25 while (i <= 10) { // 2. 条件判断 26 System.out.println("我错啦!" + i); // 3. 循环体 27 i++; // 4. 步进语句 28 } 29 } 30 }
浙公网安备 33010602011771号