You should use the StringBuilder class.

StringBuilder stringBuilder = new StringBuilder();

stringBuilder.append("Some text");
stringBuilder.append("Some text");
stringBuilder.append("Some text");

String finalString = stringBuilder.toString();

In addition, please visit:

  • "How Java optimize the code with StringBuilder?"
  • "StringBuilder vs String concatenation in toString() in Java"
Answer from Damian Leszczyński - Vash on Stack Overflow
🌐
W3Schools
w3schools.com › java › java_strings_concat.asp
Java Strings Concatenation
The + operator can be used between strings to combine them.
🌐
GeeksforGeeks
geeksforgeeks.org › java › stringbuilder-append-method-in-java-with-examples
StringBuilder append() Method in Java - GeeksforGeeks
July 11, 2025 - In Java, the append() method of StringBuilder class is used to add data to the end of an existing StringBuilder object.
🌐
Baeldung
baeldung.com › home › java › java string › string concatenation in java
String Concatenation in Java | Baeldung
January 8, 2024 - The concat() method in the String class appends a specified string at the end of the current string, and returns the new combined string.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › String.html
String (Java Platform SE 8 )
July 21, 2026 - The Java language provides special support for the string concatenation operator ( + ), and for conversion of other objects to strings. String concatenation is implemented through the StringBuilder(or StringBuffer) class and its append method. String conversions are implemented through the ...
🌐
CodeGym
codegym.cc › java blog › strings in java › append() method in java: stringbuilder and stringbuffer
Append() Method in Java: StringBuilder and StringBuffer
September 28, 2023 - The point is that String concatenation in Java is implemented using the StringBuilder or StringBuffer class and their append() method.
🌐
Coderanch
coderanch.com › t › 779364 › java › concat-Strings
+= and .concat() for Strings (Beginning Java forum at Coderanch)
February 2, 2024 - I understand that Strings are immutable in Java, and I more or less understand how that immutability works, with regards to the Strings being stored in the String Pool, etc. My question is, what is += doing differently from .concat() ?
Find elsewhere
🌐
Codecademy
codecademy.com › docs › java › stringbuilder › .append()
Java | StringBuilder | .append() | Codecademy
August 22, 2022 - The .append() method appends the string value of its argument to the StringBuilder. It returns a reference to the StringBuilder object. ... Looking for an introduction to the theory behind programming?
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-concat-examples
Java String concat() Method with Examples - GeeksforGeeks
The concat() method in Java is used to append one string to another and returns a new combined string.
Published: April 7, 2026
🌐
W3Schools
w3schools.com › java › ref_string_concat.asp
Java String concat() Method
Java Examples Java Videos Java ...lastName)); Try it Yourself » · Share Link Copied · The concat() method appends (concatenate) a string to the end of another string....
🌐
Baeldung
baeldung.com › home › java › java string › concatenating strings in java
Concatenating Strings in Java | Baeldung
May 8, 2025 - StringJoiner abstracts all of the String.join functionality into a simple to use class. The constructor takes a delimiter, with an optional prefix and suffix. We can append Strings using the well-named add method.
🌐
Medium
medium.com › @AlexanderObregon › javas-stringbuilder-append-method-explained-500b2ef84ec0
Java’s StringBuilder.append() Method Explained | Medium
August 6, 2024 - Using the StringBuilder.append() method offers significant performance advantages over traditional string concatenation using the + operator. Understanding these benefits can help you make more efficient choices in your code, especially in scenarios involving extensive string manipulation. In Java, strings are immutable, meaning that once a String object is created, it cannot be modified.
🌐
CodeSignal
codesignal.com › learn › courses › getting-started-with-java › lessons › java-string-magic-understanding-concatenation-operations
Java String Magic: Understanding Concatenation Operations
However, there are some nifty tools provided by Java, e.g., StringBuilder is a mutable sequence of characters, meaning you can alter its content without creating a new object. It provides an optimized way to concatenate strings, which is particularly useful when concatenating a large number of strings. ... StringBuilder sb = new StringBuilder(); sb.append("Hello, ").append("World!") sb.append(" What ").append("a wonderful ").append("day out there!"); System.out.println(sb.toString()); // Output: Hello, World!
🌐
Blogger
javarevisited.blogspot.com › 2015 › 01 › 3-examples-to-concatenate-string-in-java.html
3 Examples to Concatenate String in Java
You can use this operator even ... String "123". The other two ways to concatenate String in Java is by using StringBuffer and StringBuilder....
🌐
DEV Community
dev.to › joshaustintech › how-to-concatenate-strings-in-java-like-a-pro-3c33
How to Concatenate Strings in Java like a Pro - DEV Community
February 18, 2023 - StringBuilder greetAllHobbits = hobbits.stream() .reduce(new StringBuilder(), (acc, b) -> acc.append("Greetings, %s!%n".formatted(b)), StringBuilder::append); For further actions, you may consider blocking this person and/or reporting abuse · Joshua Austin · Follow · Java developer.
🌐
Educative
educative.io › answers › how-to-concatenate-strings-in-java
How to concatenate strings in Java
The += operator modifies the original string variable by adding another string to it. ... Note: As per the official Java documentation, when you use + or += to concatenate a string with a reference to an object in Java, the reference will ...
🌐
TechVidvan
techvidvan.com › tutorials › java-string-concatenation
Java String concat() Method with Examples - TechVidvan
February 17, 2025 - To perform concatenation operations, StringBuilder is a class that provides an append() method.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Fetch_API › Using_Fetch
Using the Fetch API - Web APIs | MDN
We declare a string containing the URL and then call fetch(), passing the URL with no extra options.
🌐
BeginnersBook
beginnersbook.com › 2024 › 06 › string-concatenation-in-java
String Concatenation in Java
One of the easiest and simplest way to concatenate strings in Java is using the + operator.