为什么使用 concat 函数创建的 2 个字符串和相同的字符串具有不同的对象引用?

Why 2 String created using concat function and same strings are having object reference different?

我的代码:

class TestStringConcatenation{
 public static void main(String args[]){

   String s1="Sachin ";
   String s2="Tendulkar";

   String s3=s1.concat(s2);
   String s4=s1.concat(s2);

   System.out.println(s4==s3);
  }
}

输出:

false

concat函数不是把String对象保存在字符串常量池中吗?

Is concat function not saving the String object in string constant pool?

它没有存储在 intern 池中,不。 (constant pool is a different thing.) Only string constants are automatically interned. If you want any other string interned, you have to do it explicitly, via a call to intern.