这个程序有什么问题 [英] what's wrong with this program
本文介绍了这个程序有什么问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个代码片段:
class WhileTest
{
public static void main(String s[])
{
int x=12;
while(x<13)
{
x--;
}
System.out.println(x);
}
}
上述程序的输出为:2147483647
为什么会这样?
推荐答案
x
递减然后下溢到达 Integer.MAX_VALUE
x
is decremented and then underflows reaching Integer.MAX_VALUE
这篇关于这个程序有什么问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文