为什么程序在上溢或下溢时不抛出异常

Why the program is not throwing an exception when there is an overflow or underflow

当超过整数的最大值(溢出)时,则为其分配最小值。
Ex- System.out.println(Integer.MAX_VALUE+1); 输出:-2147483648
这里不是抛出异常,而是程序 returns 一个不正确的值。
此功能如何以任何方式帮助程序员或设计人员?

它使代码 运行 更快,因为不需要在每次算术运算后检查溢出。

我只是不认为 java 的原始实现者想要检查计算是否导致溢出的开销。您可以以编程方式检查。例如,How does Java handle integer underflows and overflows and how would you check for it?

这也是传统 C 和 C++ 处理整数的方式,所以有先例。