String is an inmutable object, so its contents
cannot be changed. When you do the following:
String s = "a";
s = s + "b";
is the same that
s = new String(s + "b");
So, the first object is not referenced anymore, and
will be cleaned by the garbage collector.