他自己定义的...你可以参考jdk源码 java-lang-Integer.java文件 /** * A constant holding the minimum value an <code>int</code> can * have, -2<sup>31</sup>. */ public static final int MIN_VALUE = 0x80000000; /** * A constant holding the maximum value an <code>int</code> can * have, 2<sup>31</sup>-1. */ public static final int MAX_VALUE = 0x7fffffff;
因为int 所占的字节数为4个字节,即32位.对于正数,它的最高位是0,所以它最大能表示的数是01111....(后面共31个1),而这个数化成十进制即是2147483647.对于负数也是同理.
* A constant holding the minimum value an <code>int</code> can
* have, -2<sup>31</sup>.
*/
public static final int MIN_VALUE = 0x80000000; /**
* A constant holding the maximum value an <code>int</code> can
* have, 2<sup>31</sup>-1.
*/
public static final int MAX_VALUE = 0x7fffffff;
java已经定义了int是4byte了,那就决定了它就是这个范围,和它运行在虚拟机上这件事没有关系。即使将来有直接运行字节码的CPU,java在上面跑也是这样的。