Hi All,
The below example from K&B should help. String s1 = "spring ";
String s2 = s1 + "summer ";
s1.concat("fall ");
s2.concat(s1);
s1 += "winter ";
System.out.println(s1 + " " + s2);
The result of this code fragment is �spring winter spring summer�.
There are two reference variables, s1 and s2. There were a total of eight String objects created as follows: �spring�, �summer � (lost), �spring summer�, �fall� (lost), �spring fall� (lost), �spring summer spring� (lost), �winter� (lost), �spring winter� (at this point �spring� is lost). Only two of the eight String objects are not lost in this process.
See
String Objects [ January 30, 2006: Message edited by: Lalitha Vydyula ]
[ January 30, 2006: Message edited by: Lalitha Vydyula ]