Special string case interned in Java
I have two lines in Java code:
String str = new String("My place")
String str1 = new String("My place")
It is clear that the new String ("My place") creates two objects, one of which is related to interning and the other due to new , but I am confused as here the argument has the same literal, so the same interned an object is used by str1 which results in 3 objects or others which results in 4 objects
+3
source to share
2 answers