posted 14 years ago
The Integer wrapper class keeps track of a cache of 256 Integer objects in the range -128 to 127. If thru autoboxing a new Integer object is created for a value within that range, instead of creating a new instance, the reference to the cached instance is returned. Two Integer references can therefor point to the same object, which is why the == comparison succeeds.
Edit: Nevermind I completely missed the point of your question.
[ March 14, 2008: Message edited by: Jelle Klap ]
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.