📜  字符串与新字符串 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:42.050000             🧑  作者: Mango

代码示例1
String str = new String("");
String str2 = "";

They both immutable and they save in different 
memory location. String objects created without
the use of new keyword are stored in the
String Constant Pool part of the heap.
It doesn't create the same string object
if there is already string constant in the pool.