sum cannot be resolved to a variable错误
public class Demo10409 {
public static void main(String[] args) {
for( int sum=0,i=1;i<=100 ; i++){
if(i%3!=0){
sum=sum+i;
}
}
System.out.println("1到100之间不能被3整除的数之和为:"+sum);
}
最后的输出行如果加上sum就会显示,去掉+sum就没事 sum cannot be resolved to a variable