DoWhile循环

 1 package com.pingfan.struct;
 2 
 3 public class DoWhileDemo1 {
 4     public static void main(String[] args) {
 5         int i = 0;
 6         int sum = 0;
 7 
 8         do{
 9             sum = sum + i;
10             i++;
11         }while (i<=100);
12         System.out.println(sum);
13     }
14 }
 1 package com.pingfan.struct;
 2 
 3 public class DoWhileDemo2 {
 4     public static void main(String[] args) {
 5         int a = 0;
 6         while (a<0){
 7             System.out.println(a);
 8             a++;
 9         }
10         System.out.println("================");
11         do {
12             System.out.println(a);
13             a++;
14         }while (a<0);
15     }
16 }

 

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