Yes, calling the toString method StringBuffer and StringBuilder will create a new string object each time, since these methods use the new keyword to return the string.
Here is the code for toString from the StringBuffer class:
public synchronized String toString() { return new String(value, 0, count); }
Here is the toString method from the StringBuilder class:
public String toString() {
source share