+ 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?
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 âș
+ 16
yeah @LunarCoffee đ
+ 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. đ
+ 1
@Gaurav you're platinum now! :D
+ 1
Thanks Gaurav
0
thank you so much