how we concatinat two string code example

Example 1: concatenate a string

let myPet = 'seahorse';console.log('My favorite animal is the ' + myPet + '.'); // My favorite animal is the seahorse.

Example 2: how do you combine 2 strings

-By  using (+) operator
-By  using concatenate method (concat()).
                      String strconcat3=strconcat2.concat(strconcat);

-By StringBuffer
-String strconcat= new StringBuilder().append("matt")
                                .append("damon").toString();
                                
-By StringBuilder
- String strconcat2= new StringBuffer()
                  .append("matt").append("damon").toString();

Tags:

Misc Example