What is the best reason for using StringBuilder instead of String?
C.
Option A is incorrect because StringBuilder does not support multiple threads.
StringBuffer supports multiple threads.
Option B is incorrect because == compares references, not values.
Option D is incorrect because both String and StringBuilder support languages and encodings.
Option C is correct and the primary reason to use StringBuilder.
String often creates a new object each time you call certain methods on the object like concat()
.
StringBuilder optimizes operations like append()
because it is mutable.