...
"Ideally, boxing a given primitive value p, would always yield an identical reference. In practice, this may not be feasible using existing implementation techniques. The rules above are a pragmatic compromise. The final clause above requires that certain common values always be boxed into indistinguishable objects. The implementation may cache these, lazily or eagerly."(From section 5.1.7 of JLS 3rd Ed_)_
To convince our idea, we can take an insight of the source code of Integer of JDK 1.6.0_10 from java SE:
Code Block |
---|
 private static class IntegerCache {  private IntegerCache(){}  static final Integer cache[] = new Integer[-(-128) + 127 + 1];  static {     for(int i = 0; i < cache.length; i++)   cache  cache[i] = new Integer(i - 128);  }    } |
...