码迷,mamicode.com
首页 > 其他好文 > 详细

while_for

时间:2020-02-21 16:24:03      阅读:72      评论:0      收藏:0      [点我收藏+]

标签:oid   ++   初始   pack   color   void   system   ati   for   

package myproject;

public class TestWhile {
    public static void main(String[] args) {
        
        //while循环
        
        int b=1;//初始化
        while(b<=10) {//条件判断
            System.out.println(b);//循环体
            b++;//迭代    
        }
        
        //for循环
        for (int i=1;i<=10;i++) { //循环体结束后,再迭代
            System.out.println(i);
        }
        
        
        
        int a=1;
        int sum=0; 
        while(a<100) {     
            sum+=a;  
            a++;         
        }
        System.out.println("sum:"+sum);
        
        
        
        
    }
}

 

while_for

标签:oid   ++   初始   pack   color   void   system   ati   for   

原文地址:https://www.cnblogs.com/hapyygril/p/12341694.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!