Re:First Impressions of Python from a Java Developer
by jrockway on Monday November 08, 2010 @03:45PM
(#1883921)
It's simple, right? The result of <Integer> == <Integer> is undefined with respect to the value that is stored in the Integer object.
[ Parent
| on HN ]
Re:First Impressions of Python from a Java Developer
by RodgerTheGreat on Monday November 08, 2010 @06:07PM
(#1884443)
A bit more subtle than that- Java reserves singleton instances of Integer for values in the range -128 to 127. In these cases, the Integers will contain the same value and refer to the same object, so == works. It's not actually undefined behavior.