+ 5
challange explanation
What is the output of this code? Integer i1 = 127; Integer i2 = 127; System.out.println(i1 == i2); i1 = 128; i2 = 128; System.out.println(i1 == i2); why the answer is true false
3 odpowiedzi
+ 2
Additionally Hope these may help you..
https://www.sololearn.com/Discuss/1930263/?ref=app
https://www.sololearn.com/Discuss/2132457/?ref=app
+ 1
I remember slightly someone mentioned about value caching for Java Integer. As I recall, value of Integer from -128 up to 127 was cached in memory, and its reference is reused when another Integer was created, and assigned a value within that range (-128 ~ 127).
A bit like string pool work for efficiency I guess (cmiiw).
+ 1
.