C4learn - Java Concatenate Strings
C4learn - Java Concatenate Strings
o
o
o
Output :
Complete Statement : I love my country India
Complete Statement : India1010
Complete Statement : 20India
Operand 2
Result of Concatenation
Integer
String
String
String
String
String
Integer
Integer
Integer
1.
2. Each time + operator will check the type of operands and then
decide which operation to perform.
3. If any of the operand is of type String then another type will
converted to String using respective wrapper classes.
First Concatenation :
myString =
=
=
=
Second Concatenation :
myString =
=
=
=
Str3 + 10 + 10;
"India" + 10 + 10
"India10" + 10
"India1010"
Third Concatenation :
myString =
=
=
=
10 + 10 + Str3;
10 + 10 + "India"
20 + "India"
"20India"