1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-16 18:10:13 +08:00

Update memory-area.md

有个错误 在缓存 i2写成i1
This commit is contained in:
ZhoucpSAMA 2022-01-20 03:17:39 -06:00 committed by GitHub
parent b40c4ebd88
commit 21a7805c93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -562,7 +562,7 @@ Integer i2 = new Integer(40);
System.out.println(i1==i2); System.out.println(i1==i2);
``` ```
`Integer i1=40` 这一行代码会发生装箱,也就是说这行代码等价于 `Integer i1=Integer.valueOf(40)` 。因此,`i1` 直接使用的是常量池中的对象。而`Integer i1 = new Integer(40)` 会直接创建新的对象。 `Integer i1=40` 这一行代码会发生装箱,也就是说这行代码等价于 `Integer i2=Integer.valueOf(40)` 。因此,`i1` 直接使用的是常量池中的对象。而`Integer i1 = new Integer(40)` 会直接创建新的对象。
因此,答案是 `false` 。你答对了吗? 因此,答案是 `false` 。你答对了吗?