首页 > 编程语言 > 详细

JAVA今日2021.8.6

时间:2021-08-06 23:59:33      阅读:31      评论:0      收藏:0      [点我收藏+]

JAVA while循环

while循环结构

while(布尔表达式){
    //循环内容
}

while01

package JAVASE.struct;

public class while01 {
    public static void main(String[] args) {
        //输出1-100
        int i = 0;
        while (i<100){
            i++;
            System.out.println(i);
        }
    }
}

while02

package JAVASE.struct;

public class while02 {
    public static void main(String[] args) {
        //1+2+3+...+100=
        int i = 0;
        int s = 0;
        while (i<100){
            i++;
            s = s+i;
        }
        System.out.println(s);
    }
}

2021.8.6

JAVA今日2021.8.6

原文:https://www.cnblogs.com/Walf1234/p/15110642.html

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