java流程控制之 while 循环 1到100的和
package struct;
public class Demo03 {
public static void main(String[] args) {
text();
System.out.println("------------");
text2();
}
public static void text() {
int i = 0;
while (i < 100) {
i++;
System.out.println(i);
}
}
public static void text2(){
int i=0;
int sum=0;
while (i<=100){
sum+=i;
i++;
}
System.out.println(sum);
}
}