修复 jvm第九章

This commit is contained in:
Dragon
2021-01-14 21:12:50 +08:00
parent 2f1d80bf10
commit 93b29b1a5f

View File

@@ -950,7 +950,7 @@ public class StringNewTest {
* String s = new StringBuilder("shkstart").toString().intern();
*
*/
public class StringIntern {
public class StringIntern {
public static void main(String[] args) {
String s = new String("1");
@@ -970,7 +970,7 @@ public class StringIntern {
4、所以在JDK7后续版本中s3和s4指向的完全是同一个地址。
*/
String s3 = new String("1") + new String("1");//pos_1
s3.intern();
String s4 = "11";//s4变量记录的地址使用的是上一行代码代码执行时在常量池中生成的"11"的地址
System.out.println(s3 == s4);//jdk6false jdk7/8true