A String "A" when edited by adding a new string "B" to it will be creating a new instance and storing the string "AB" in a new memory location discarding "A". StringBuilder on the other hand is preferred because the new string is added to the current string in the same location.
string builder s more efficent in the cases where a lot of manipulation s done to the text string are immutiable,so each time its being operatingon a new instance s created
2 comments:
A String "A" when edited by adding a new string "B" to it will be creating a new instance and storing the string "AB" in a new memory location discarding "A". StringBuilder on the other hand is preferred because the new string is added to the current string in the same location.
string builder s more efficent in the cases where a lot of manipulation s done to the text string are immutiable,so each time its being operatingon a new instance s created
Post a Comment