Java String concat() method

String concat() is used to concatenate two strings. The parameter str string is appended to specified string and new string object is returned by this method.
“Hello ”.concat(“Friends”)
This will generate a new string object “Hello Friends”


Str – is string parameter used to concatenate with specified string


Here str is concatenated with ” ” then it is concatenated with str1 and result is assigned to str3 String object.