非字符串池字符串+字符串池字符串是否指向字符串池?

时间:2019-12-01 22:26:07

标签: java pointers memory heap string-pool

service_SC30COM_####_20191130_1834.zip

我认为它指向字符串池,所以我进行了测试:

String test=new String("apple"); // test pointing outside string pool
String newtest=test+"banana";  // Is it pointing outside the string pool??

但是输出为false,这意味着newtest没有指向字符串池,这非常违反直觉。有谁可以帮助我吗?我需要一个专家。

0 个答案:

没有答案