public class GOOD{
public static void main(String[]args){
int x;
int sum =0;
for (x=2;x<=100;x+=2){
sum+=x;
}
System.out.println(sum);
}
}
---------------------------------------------------------------
public class GOOD{
public static void main(String[]args){
int x;
int sum =0;
for (x=2;x<=100;){
x+=2;
sum+=x;
}
System.out.println(sum);
}
}
两次结果不一样,for (x=2;x<=100;)有无冒号也有差异 |