Tag

ReferenceEquality

1 views collected around this technical thread.

IT Xianyu
IT Xianyu
Jan 24, 2022 · Fundamentals

Why does Java evaluate 1000==1000 as false while 100==100 evaluates to true?

The article explains that Java's Integer caching for values between -128 and 127 causes small integer objects to be shared, making == true for 100, whereas larger integers like 1000 are distinct objects, so == returns false, and it demonstrates this behavior with code and reflection examples.

IntegerJavaReferenceEquality
0 likes · 4 min read
Why does Java evaluate 1000==1000 as false while 100==100 evaluates to true?