1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-25 02:27:10 +08:00

Merge pull request #1465 from Sheldon7777/main

Create memory-area.md
This commit is contained in:
Guide哥 2021-12-03 20:14:59 +08:00 committed by GitHub
commit 5b97792e62
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() {