参考jdk文档,可以看到如下注释
Note that if the argument is equal to the value of Integer.MIN_VALUE
, the most negative representable int
value, the result is that same value, which is negative.
public class Test {
public static void main(String[] args) {
System.out.println(Integer.MIN_VALUE);
System.out.println(Integer.MIN_VALUE < 0);
System.out.println(Math.abs(Integer.MIN_VALUE));
System.out.println(Math.abs(Integer.MIN_VALUE) < 0);
System.out.println(Integer.MAX_VALUE + 1);
}
}
结果如下
-2147483648
true
-2147483648
true
-2147483648