Java Example – String concatenation (join strings)

String concatenation is the operation of joining character strings end-to-end.
In this Java example we will see How to concatenate Strings in Java.
The String concatenation in Java can be done in several ways.

  1. Using + operator – When we use + operator string_1 + string_2 statement, it would be executed as, new StringBuffer().append(string_1 ).append(string_2) Internally. + operator is not recommended for large number of String concatenation as the performance is not good.
  2. Using String.concat() method – oncatenates the specified string to the end of this string.
  3. Using StringBuffer.append method – Appends the specified StringBuffer to this sequence.


Partner Sites