Java语言规范指出:特定的基本类型一定得被装箱成包装对象。这些对象会被高速缓存以重复使用,并且会被当作一般使用的对象。这些特殊的值是:
boolean: true、false
byte: 所有的值
short、int和long: -128~127
char: \u0000~\u007F
float和double:不会被缓存
Java Language Specification 中的相关章节
If the value p being boxed is true, false, a byte, a char in the range
\u0000 to \u007f, or an int or short number between -128 and 127, then
let r1 and r2 be the results of any two boxing conversions of p. It is
always the case that r1 == r2.