为什么不能再for后定义sum
for (int i = 1, int sum=0; i <= 5; i++){ if(i % 3 != 0) { sum = sum + i; } } System.out.println("和为"+ sum);
将int sum置于for()内时,为何报错?
for (int i = 1, int sum=0; i <= 5; i++){ if(i % 3 != 0) { sum = sum + i; } } System.out.println("和为"+ sum);
将int sum置于for()内时,为何报错?
2016-11-18
举报