4 ms·
Why does 128==128: false but 127==127: true when converting to Integer wrappers?
- du_bing 10y agoYeah, I have encounter this interesting problem. To put it simple, -128~127 is directly stored in the RAM, when compared, the program only compares the real value of the number. But when a number is 128 or other, the program will compare both the location and value of the number.
- peterashford 10y agoEveryone using Java knows that you need to use .equals() for comparing Objects, not ==.