String s = s1 + s2
Behind the scenes this is translated to:
String s = new StringBuilder(s1).append(s2).toString();
after the toString() call, nothing references the StringBuilder object anymore.
so, the StringBuilder object will be GCed.
Behind the scenes this is translated to:
String s = new StringBuilder(s1).append(s2).toString();
after the toString() call, nothing references the StringBuilder object anymore.
so, the StringBuilder object will be GCed.