StringBuilder optimization (ARCH4071)
Esta página aún no está disponible en tu idioma.
Key java.performance.string-builder-optimization · Severity info · Category performance
Joining many + operands in a single expression hurts readability and can produce needless intermediate objects. Multi-part joins should use a builder or String.join.
Incorrect
Section titled “Incorrect”String line = a + "-" + b + "-" + c + "-" + d + "-" + e + "-" + f;return line;Correct
Section titled “Correct”String line = String.join("-", a, b, c, d, e, f);return line;Replace multi-operand concatenation chains with String.join or a StringBuilder.