Zum Inhalt springen

StringBuilder optimization (ARCH4071)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

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.

String line = a + "-" + b + "-" + c + "-" + d + "-" + e + "-" + f;
return line;
String line = String.join("-", a, b, c, d, e, f);
return line;

Replace multi-operand concatenation chains with String.join or a StringBuilder.