posted 11 years ago
Yes. This is confusing.
For all Integer with values < 128 , those Integer instances work just like primitive. So, all those values can be compare by the == sign.
But all Integer with values >=128, they are treated as object. If the references refer to the same object, then " i1==i2" is true; otherwise, false.
Of course , when their values are the same, using .equal methods will return true.
For more detail, please refer to autoboxing in KB's book.