public class WhileDemo01 {public static void main(String[] args) {// 输出 1 ~ 100int i = 0;while (i<100) {i++;System.out.println(i);}// 计算 1+2+3+4...+100=?int j = 0;int sum = 0;while (j<=100){sum = sum + j;j++;}System.out.println(sum); // 5050}
}
https://www.bilibili.com/video/BV12J41137hu?p=38&spm_id_from=pageDriver