package study01; public class TestWhile { public static void main(String[] args) { int sum = 0; int i = 1; while (i <= 100) { System.out.println(i); sum += i; i++; } System.out.println(sum); } }
结果等于
5050
package study01; public class TestWhile { public static void main(String[] args) { int sum = 0; int i = 1; while (i <= 100) { System.out.println(i); sum += i; i++; } System.out.println(sum); } }
结果等于
5050