public class Test{
public static void main(String[] args){
int count = 0;
for(int i=0; i<100; i++){
count += count++;
}
System.out.println(count);
}
}
//输出结果:
// 0
//分解步骤:
// count = count + count++; 这个肯定大家都会,恭喜你正在往错误的边缘靠近
// int temp = count + count; 姑且定义一个临时变量吧,这个应该不用解释吧
// count++; 终于轮到++操作了
// count = tem; 赋值永远要等到最后,是不是一步步走向错误的边缘?
这道面试题貌似很简单噢!
最新推荐文章于 2024-06-23 04:06:09 发布