while(布尔表达式){ //循环内容 }
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); } } }
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