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
🌐
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.
🌐
W3Schools
w3schools.com › java › java_strings_concat.asp
Java Strings Concatenation
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Practice Problems Java Server Java Syllabus Java Study Plan Java Interview Q&A ... The + operator can be used between strings to combine them.
🌐
Medium
medium.com › @AlexanderObregon › javas-stringbuilder-append-method-explained-500b2ef84ec0
Java’s StringBuilder.append() Method Explained | Medium
August 6, 2024 - Learn the mechanics, performance benefits, and use cases of Java's StringBuilder.append() method for efficient string concatenation and data manipulation.
🌐
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.
🌐
Baeldung
baeldung.com › home › java › java string › concatenating strings in java
Concatenating Strings in Java | Baeldung
May 8, 2025 - In this example, our chain is started with a String literal, the concat method then allows us to chain the calls to append further Strings. Next up is the String.format method, which allows us to inject a variety of Java Objects into a String template.
🌐
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?
🌐
W3Schools
w3schools.com › java › ref_string_concat.asp
Java String concat() Method
Java Examples Java Videos Java ... System.out.println(firstName.concat(lastName)); ... The concat() method appends (concatenate) a string to the end of another string....
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › java › lang › stringbuilder_append_string.htm
Java.lang.StringBuilder.append() Method
The java.lang.StringBuilder.append(String str) method appends the specified string to this character sequence.The characters of the String argument are appended, in order, increasing the length of this sequence by the length of the argument.
🌐
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 - append() is a Java method of StringBuilder and StringBuffer classes that appends some value to a current sequence. Even if you didn't know what the append() method is, you probably already used it implicitly.
🌐
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
🌐
Delft Stack
delftstack.com › home › howto › java › java append to string
How to Append Strings in Java Efficiently | Delft Stack
February 2, 2024 - When we talk about string concatenation in Java, the + operator comes to mind to append strings most efficiently. Since Java does not provide support for overloading, it is special for strings to have such behavior.
🌐
Vultr Docs
docs.vultr.com › java › standard-library › java › lang › String › concat
Java String concat() - Concatenate Strings | Vultr Docs
November 19, 2024 - java Copy · String firstString = "Hello"; String secondString = " World!"; String result = firstString.concat(secondString); System.out.println(result); Explain Code · This code snippet will output "Hello World!". The concat() method effectively ...
🌐
Medium
medium.com › @AlexanderObregon › beginners-guide-to-java-string-concatenation-1e2fbccda0bc
Beginner’s Guide to Java String Concatenation
March 26, 2024 - The concat() method is a part of the String class and offers a more explicit approach to string concatenation. This method takes a single string argument and appends it to the string it is called on, returning a new string as the result.
🌐
Just Academy
justacademy.co › blog-detail › how-to-append-string-in-java
How To Append String In Java by Roshan Chaturvedi | JustAcademy
Overall, appending strings in Java ... (+). This operator allows you to combine multiple strings together into a single string.2) Another way to append strings in Java is by using the concat() method provided by the String class....
🌐
GeeksforGeeks
geeksforgeeks.org › java › stringbuffer-append-method-in-java-with-examples
StringBuffer append() Method in Java with Examples - GeeksforGeeks
July 11, 2025 - public StringBuffer append(boolean ... value to be appended. Return Value : The method returns a reference to this object. Examples: Input: string_buffer = "I love my Country" boolean a = true Output: I love my Country true Below program illustrates the java.lang.StringBuff...
🌐
Medium
amrsaeedhosny.medium.com › how-to-concatenate-strings-in-java-6387cfd73634
How to Concatenate Strings In Java? | by Amr Saeed | Medium
September 1, 2023 - The StringBuilder class is a class that implements the CharSequence interface in Java. It is the same interface the String class implements. StringBuilder class implements Serializable, Comparable, and CharSequence. As mentioned earlier, the StringBuilder is the mutable version of the string, which means that it allows modifying the content without creating new objects. That’s why the StringBuilder is more efficient when it comes to string operations. String message = new StringBuilder("He").append("ll").append("o!").toString();
🌐
CodeGym
codegym.cc › java blog › strings in java › string concatenation in java
String Concatenation in Java
April 1, 2025 - public class StringConcat { public static void main(String[] args) { String myString = "Code" + "Gym"; myString+= ".cc"; System.out.println(myString); } } Usually Java doesn’t allow overloading operations for user classes, but these two operators work as overloaded. You might think that inside the + operator is hiding concat(), but in fact, another mechanism is used here. If we look at the Java program bytecode, we’ll see that StringBuilder was created and its append() method is used.
🌐
Blogger
javarevisited.blogspot.com › 2015 › 01 › 3-examples-to-concatenate-string-in-java.html
3 Examples to Concatenate String in Java
The reason for the slowness when appending many strings in a loop using the + operator is that the + operator creates and disposes of a new StringBuffer for every + operator. So not only are you creating many small String objects, but each one of them was created by a temp StringBuffer object.