From the post String Builder Replace() is faster then string replace() in .NET language
I want to know if same answer is valid for java as well or not.
I checked and found
StringBuilder builder = ...;
builder = new StringBuilder(builder.toString().replace("from", "to"));
is inefficient as StringBuilder.toString()
is an expensive operation.
Why JAVA does not have replace
method in string builder class ?