string vs new string code example
Example: string vs new string
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.