Java string concat method is used to concatenate two or more than two strings to a single string. This method mainly appends the string at the end of the main string. For example: If we have two strings, “Hello” and “World” and we want to concatenate them, then the result will be “HelloWorld.”

Concat() In Java Example

In Java language, the string concatenation forms the new string that is a combination of the multiple strings. There are two ways to concat the string in Java:

  1. By + (string concatenation) operator
  2. By concat() method

Java String concat() method concatenates one  string to an end of another string. The concat() method returns a string with the value of the string passed in to the method, appended to the end of the string.

Syntax

public String concat(String str)

Here str is the string to be concatenated at the end of the first string.

The method returns a single string by concatenating more than one strings.

#concat #java #helloworld #java string concat

Concat() In Java Example | Java String Concat() Method
3.95 GEEK