mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-06-16 18:10:13 +08:00
Update Java内存区域.md
This commit is contained in:
parent
2c1d1704fc
commit
437abe688a
@ -615,7 +615,7 @@ System.out.println(i4 == i5 + i6);// true
|
||||
System.out.println(40 == i5 + i6);// true
|
||||
```
|
||||
|
||||
`i1`, `i2 `,`i3` 都是常量池中的对象,`i4` ,`i5` , `i6` 是堆中的对象。
|
||||
`i1` , `i2 ` , `i3` 都是常量池中的对象,`i4` , `i5` , `i6` 是堆中的对象。
|
||||
|
||||
`i4 == i5 + i6` 为什么是 true 呢?因为, `i5` 和 `i6` 会进行自动拆箱操作,进行数值相加,即 `i4 == 40` 。 `Integer` 对象无法与数值进行直接比较,所以 `i4` 自动拆箱转为 int 值 40,最终这条语句转为 `40 == 40` 进行数值比较。
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user