String object is read only (immutable) that means string object cannot be
modified .Some methods seems to modify the string object but actually they
are not modifying the object but creating the new object.

String builder object is mutable ,it can modify the object by
appending,removing,replacing etc.
Here when the object is modified it is refering to the same instance where
as in string class a new object is creates

Performance:

Concat method of String class and Append Method of StringBuilder class both
concatenate 2 strings.But the string class creates new object from existing
object which allocates memory where as A StringBuilder object maintains a
buffer to accommodate the concatenation of new data. New data is appended to
the end of the buffer if room is available; otherwise, a new, larger buffer
is allocated, data from the original buffer is copied to the new buffer,
then the new data is appended to the new buffer.

On Thu, Feb 5, 2009 at 1:27 PM, Brandon Betances <[email protected]>wrote:

> 2nd. The first one takes up too much memory. The variables are declared,
> just add them to your string.
>



-- 
Thanks & Regards
Harika
http://harikaworks.blogspot.com

Reply via email to