The range is actually -128 to 127. If the value it fall outside the range valueOf doesnt work..rather new objects are created..making them unequal.
This is a nitpick... The java specification merely states the range that must be cached. It does *not* state what happens to values that fall out of the range. It is perfectly valid to have a JVM implementation, that caches a larger range, and hence, have the same object after autoboxing.