+ 3

String Concatination

String firstName, lastName; firstName = "David"; lastName = "Williams"; System.out.println("My name is " + firstName +" "+lastName); this is the code that you shown there string concatenation. There is no concatenation occuring in the code you just printed that two names with a space between them. what's the actual meaning of concatenation?concatenation means joining or link together. You did nothing there like that

12th Nov 2017, 4:57 AM
Santhosh Selvam
Santhosh Selvam - avatar
7 Answers
+ 31
+ is overloading operator in java //for numbers it adds , for strings it concatinates example ::: int a=1+2; String b="abc"+"zyx";
12th Nov 2017, 6:05 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 13
What the code did is it concatenated all of the strings first, then print it out as a new string. It didn't print it one by one.
12th Nov 2017, 5:03 AM
qwerty
qwerty - avatar
+ 3
what is the error you are getting because code looks fine
12th Nov 2017, 4:59 AM
shobhit
shobhit - avatar
+ 3
+ dont acts as seperator in java
12th Nov 2017, 5:32 AM
shobhit
shobhit - avatar
+ 2
the concatenation operator is +.right In java the work of separator is also done by the symbol +,where as in C comma(,) is used as the separator. I need to know ,in that code ,where the symbol '+' acts as a separator and where does it acts as string concatenation operator
12th Nov 2017, 5:26 AM
Santhosh Selvam
Santhosh Selvam - avatar
+ 2
ok ,tanz
12th Nov 2017, 5:34 AM
Santhosh Selvam
Santhosh Selvam - avatar
0
but Java doesn't support operator overloading......
12th Nov 2017, 7:08 AM
Santhosh Selvam
Santhosh Selvam - avatar