19为什么这么选 如果是i-1呢。请详细讲讲

img

Integer.MIN_VALUE - 1 = Integer.MAX_VALUE = 2^31 -1
Integer.MIN_VALUE - 1L 自动转为Long型 即为 Integer.MAX_VALUE - 1L = -2^31 -1
2^31 -1 +(-2^31 -1) = -1-1 =-2

首先int i = integer.xxx没有值,所以赋默认值0,之后i-1为-1,i-1l这里有一个数据转换的概念,还是为-1,所以-1 + (-1)为-2

i-1为-1