For循环详解

 1 package com.pingfan.struct;
 2 
 3 public class ForDemo1 {
 4     public static void main(String[] args) {
 5         int a = 1;//初始化条件
 6 
 7         while (a<100){//条件判断
 8             System.out.println(a);//循环体
 9             a+=2;//迭代
10         }
11         System.out.println("While循环结束!");
12 
13         //初始化//条件判断//迭代
14         for (int i = 1; i < 100; i++) {
15             System.out.println(i);
16         }
17         System.out.println("for循环结束!");
18     }
19 }

 

posted @ 2021-03-22 22:57  HeartlessHero  阅读(38)  评论(0)    收藏  举报