Integer i3 = Integer.valueOf(129); Integer i4 = Integer.valueOf(129); System.out.println(i3==i4);
时间: 2024-05-20 20:19:36 浏览: 119
Java Integer.ValueOf()的一些了解
The output of this code will be false.
This is because the Integer class caches frequently used values between -128 and 127, so when we use Integer.valueOf() to create an Integer object with a value within this range, it will return the same object instance for the same value. However, in this case, the value 129 is outside of this range, so two separate object instances will be created and compared using ==, which checks if they are the same object in memory. Therefore, the output will be false.
阅读全文