For performing repeated modification on string which class is preferred

A) String
B) StringBuilder
C) Both

Showing Answers 1 - 5 of 5 Answers

Prabir Sarkar

  • Jan 3rd, 2006
 

StringBuilder

  Was this answer useful?  Yes

samiksc

  • Jan 9th, 2006
 

Answer B is correct. StringBuilder class is preferred for performing repeated operations on string since its value is mutable. String class represents a text value which is immutable. All operations on string class which appear to be modifying its value actually return the new value.

So for modifying text contents StringBuilder class is preferred.

string builder is mutable and string is immutable.Immutable means whose contents can't be modified.Mutable objects are the objects whose content can be change.so performing repeated modification on string we can use string builder class.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions