+ 2

In string concatenation what is the use of ""between two variables?

When I wrote "My name is "+firstname+lastname It printed the same text as "My name is"+firstname+""+lastname would give. So what is the use of ""between firstname and lastname?

31st Dec 2017, 5:34 AM
Shalini Jha
Shalini Jha - avatar
6 Answers
+ 21
String firstname="Gaurav",lastname="Agrawal"; String str="my name is " + name +" "+ lastname; //might is was " " , not "" //" " is used to provide some space between firstname & lastname //if we have not used " " , then str will be "GauravAgrawal" //when we use " " , then str will be "Gaurav Agrawal" //hope it helps â˜ș
31st Dec 2017, 5:43 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 16
yeah @LunarCoffee 😃
2nd Jan 2018, 6:50 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 10
No difference as it's indicating an empty string was used. Otherwise it's most likely a space like this " " to separate words in between. 😉
31st Dec 2017, 5:46 AM
Zephyr Koo
Zephyr Koo - avatar
+ 1
@Gaurav you're platinum now! :D
31st Dec 2017, 6:42 AM
LunarCoffee
LunarCoffee - avatar
+ 1
Thanks Gaurav
31st Dec 2017, 6:47 AM
Shalini Jha
Shalini Jha - avatar
0
thank you so much
3rd Jan 2018, 1:02 PM
Maryam Ben Abbou
Maryam Ben Abbou - avatar