Java 基础 219行笔误

应是 s5 == s6
This commit is contained in:
Yif_Corleone 2018-09-13 18:08:37 +08:00 committed by GitHub
parent 3c9580f81d
commit b88cef16b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -216,7 +216,7 @@ System.out.println(s3 == s4); // true
```java
String s5 = "bbb";
String s6 = "bbb";
System.out.println(s4 == s5); // true
System.out.println(s5 == s6); // true
```
在 Java 7 之前String Pool 被放在运行时常量池中,它属于永久代。而在 Java 7String Pool 被移到堆中。这是因为永久代的空间有限,在大量使用字符串的场景下会导致 OutOfMemoryError 错误。