Given the 2 toString()
implementations below, which one is preferred:
public String toString(){
return \"{a:\"+ a + \", b:\" + b + \", c: \"
I think we should go with StringBuilder append approach. Reason being :
The String concatenate will create a new string object each time (As String is immutable object) , so it will create 3 objects.
With String builder only one object will created[StringBuilder is mutable] and the further string gets appended to it.