Let’s break down why string concatenation with
+ and
+= inside loops leads to extra copying, how to efficiently assemble multi-line text using
StringBuilder (methods
append(),
appendLine(), finalizing via
toString()), when it’s easier to use
joinToString(), and which mistakes most often happen when formatting reports and line breaks.