首页 > 其他 > 详细

while

时间:2017-09-28 22:14:31      阅读:221      评论:0      收藏:0      [点我收藏+]
 1 public class TestWhile {
 2 
 3     /**
 4      * 测试循环
 5      */
 6     public static void main(String[] args) {
 7         int a=1;
 8         while(a<=100){
 9             System.out.println(a);
10             a++;
11         }
12         System.out.println("while循环结束了 ");
13         //1+2+3+4+5....+100=?
14         int b=1;
15         int sum=0;
16         while(b<100){
17             //sun+=b;
18             sum=sum+b;
19             b++;
20         }
21         System.out.println("从1加到100的和是:"+sum);
22 
23     }
24 }

 

while

原文:http://www.cnblogs.com/PoeticalJustice/p/7608740.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!