According to
JLS 5.1.7 - Boxing Converson...
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.
In case 1, the int values are outside the range of -128 and 127, so there is no guarantee that they will box to the same wrapper instance. The != comparison is true.
In case 2, the int value are within the range of -128 and 127, so they box to the same wrapper instance. Here, the == comparison is true.
[ October 08, 2007: Message edited by: marc weber ]