Pages

Monday, 16 June 2014

Difference Between String and StringBuilder




String

String Builder 

1. String is Immutable type.

1. StringBuilder is mutable type.
2. Existing object cannot be modified rather creates new object in the String pool. 

2. Existing object can be modified and and doesn't create any new object in heap. 
3. String is Thread Safe.

3. StringBuilder is not Thread Safe.

4. Many Unused object left to be garbage collected if many String object are modified. 

4. Unused objects are not left to be garbage collected.

No comments:

Post a Comment