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

Create memory-area.md

This commit is contained in:
Sheldon7777 2021-11-29 15:57:48 +08:00 committed by GitHub
parent 28db32cfb4
commit 6de1dae7c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -363,7 +363,7 @@ String str4 = new StringBuilder().append(str1).append(str2).toString();
final String str1 = "str";
final String str2 = "ing";
// 下面两个表达式其实是等价的
String c = "str" + "str2";// 常量池中的对象
String c = "str" + "ing";// 常量池中的对象
String d = str1 + str2; // 常量池中的对象
System.out.println(c == d);// true
```
@ -377,7 +377,7 @@ System.out.println(c == d);// true
```java
final String str1 = "str";
final String str2 = getStr();
String c = "str" + "str2";// 常量池中的对象
String c = "str" + "ing";// 常量池中的对象
String d = str1 + str2; // 在堆上创建的新的对象
System.out.println(c == d);// false
public static String getStr() {