请一步解释如果可能的话为什么此代码显示输出17而不是16?
package array;
public class array3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int result = 0;
for (int i = 0; i < 5; i++) {
if (i == 3) {
result += 10;
} else {
result += i;
}
}
System.out.print(result);
}
}
你真的需要转向堆栈溢出吗?所以有人建议你在你的IF块中添加print语句来判断发生了什么? – GhostCat
而不是要求美国一步一步地向你展示为什么输出是17而不是16,你应该告诉我们为什么你忽略16(一步一步;)) – Peanut
如果你使用IDE,你还应该检查调试模式和使用的断点.. – Loci