Skip to content

Replace string concatenation with StringBuilder #10

@Sternbach-Software

Description

@Sternbach-Software

In java, strings are immutable objects, so adding strings together creates multiple strings in memory which the garbage collector then needs to spend time freeing up. This means more memory consumed and more processing time necessary.

The solution is to replace

String s = "";
s += getString();

with

StringBuilder s = new StringBuilder();
s.append(getString());

Examples:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions