Difference between string object and string literal [duplicate]
When you use a string literal the string can be interned, but when you use new String(“…”) you get a new string object. In this example both string literals refer the same object: String a = “abc”; String b = “abc”; System.out.println(a == b); // true Here, 2 different objects are created and they have … Read more