Given the 2 toString()
implementations below, which one is preferred:
public String toString(){
return \"{a:\"+ a + \", b:\" + b + \", c: \"
For simple strings like that I prefer to use
"string".concat("string").concat("string");
In order, I would say the preferred method of constructing a string is using StringBuilder, String#concat(), then the overloaded + operator. StringBuilder is a significant performance increase when working large strings just like using the + operator is a large decrease in performance (exponentially large decrease as the String size increases). The one problem with using .concat() is that it can throw NullPointerExceptions.