All comparison between the wrapper class object values, all compared using the equals method.

All comparison between the wrapper class object values, all compared using the equals method.

? Description: For assignment Integer var = -128 to 127, Integer object is generated IntegerCache.cache will reuse existing object, Integer values within this range may be used directly for determination ==, but this interval All data outside, the heap will be produced, not reusing existing object, which is a pit, is determined using the equals method recommended.

A = 235 Integer;
Integer B = 235;
IF (a.equals (B)) {
// code
}

Guess you like

Origin www.cnblogs.com/gouAbai/p/11280619.html
Recommended