2 ms·
It's simple, right? The result of <Integer> == <Integer> is undefined with respect to the value that is stored in the Integer object.
by jrockway 16y ago
It's simple, right? The result of <Integer> == <Integer> is undefined with respect to the value that is stored in the Integer object.
- RodgerTheGreat 16y agoA 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.