do-while
先自行后判断,即使不满足条件,也要执行一次
package scruct; public class DoWhileDemo01 { public static void main(String[] args) { //1+2+3+4````+100? int i =0; int sun=0; do{ sun=sun+i; i++; }while (i<=100); System.out.println(sun); } }
先自行后判断,即使不满足条件,也要执行一次
package scruct; public class DoWhileDemo01 { public static void main(String[] args) { //1+2+3+4````+100? int i =0; int sun=0; do{ sun=sun+i; i++; }while (i<=100); System.out.println(sun); } }