gpt4 book ai didi

Java 字符串 : Constant pool

转载 作者:行者123 更新时间:2023-11-30 05:51:27 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Questions about Java's String pool

String s1 = "length";
String s2 = "length";
System.out.println("EQUAL: " + (s1 == s2));
String s3 = "length: 10";
String s4 = "length: " + s3.length();
System.out.println(s3.length());
System.out.println(s4.length());
System.out.println("EQUAL: " + (s3 == s4));

输出:

EQUAL: true//理解字符串池中相同的字符串引用

10

10

EQUAL: false//为什么?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com