What is the difference between these two lines?
stringBuilder.append("Text " + counter + " more text");
stringBuilder.append("Text ").append(counter).append(" more text");
Assuming that counter is an incrementing int, does the first line create a String "Text 0 more text"
, "Text 1 more text"
, etc. each time it's called, while the second line creates only these two Strings once: "Text "
and " more text"
? Is this correct?