Wrapper class Integer a=10, Integer b=10 a==b

Integer a=10,100,1000;
Integer b=10,100,1000;
a==b
true when a and b are 10,100, false
when a and b are 1000. Because
Integer has a constant pool, all numbers from -128 to 127 are initialized at one time
== The memory address is compared.
When the assignment range is not exceeded, the memory address is the address in the constant pool, which
exceeds the int After each new object is created after the maximum cache size, the two addresses are definitely different.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324932139&siteId=291194637