# concatenating strings just means combining strings together
# it is used to add one string to the end of another
# below are two exmaples of how concatenation can be used
# to output 'Hello World':
# example 1:
hello_world = "Hello" + " World"
print(hello_world)
>>> Hello World
# example 2:
hello = "Hello"
print(hello + " World")
>>> Hello World
//Java
String firstName = "BarackObama";
String lastName = " Care";
//First way
System.out.println(firstName + lastName);
//Second way
String name = firstName + lastName;
System.out.println(name);
//Third way
System.out.println("BarackObama" + " Care");
-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();
let myPet = 'seahorse';console.log('My favorite animal is the ' + myPet + '.'); // My favorite animal is the seahorse.