0

System.out.println("my name is"+Firstname+" "+Secondname); Explain what is the need of " " in the middle?

string Firstname="David",secondname="mohan";

13th Oct 2016, 6:36 PM
Shafiya Nizam
9 Answers
+ 6
Hello Shafiya, if you did not insert the " ", your output would be: my name is Davidmohan. As you inserted the space, you will have: my name is David mohan. Actually you could have set your first string to "David ", so the output would already have the "space", or you could also set the second string to " mohan", which would give you the same result. Hope it helped.
13th Oct 2016, 7:14 PM
Carlos Antunes
Carlos Antunes - avatar
+ 1
the +" "+ is to insert a whitespace between first and last name. The blank space between the quotations is what you are inserting.
25th Oct 2016, 2:13 AM
nathan
nathan - avatar
0
the " " is the statement you want to print as your out put. so when you run it, it should say: my name is David mohan
13th Oct 2016, 6:57 PM
Aquarius
Aquarius - avatar
0
It adds a space. The alternitive would be to write something like: string firstname = "David "
13th Oct 2016, 9:08 PM
Craig Bell
Craig Bell - avatar
0
you need a " + " and do it so String Firstname ="David", secondname ="mohan"; thats Looks mich better i think
14th Oct 2016, 7:59 AM
Alpha Plays
Alpha Plays - avatar
0
It's just SPACE character!
16th Oct 2016, 5:49 PM
AmirHosein Mansoori
AmirHosein Mansoori - avatar
0
The " " in between actually creates a new string without creating a new variable, which helps to save memory. The + sign between the variable and the string actually serves the purpose of concatenating the tow strings
18th Oct 2016, 4:27 PM
Prarabdh Garg
Prarabdh Garg - avatar
0
Thats because to show the JVM to print it there "In between"
20th Oct 2016, 7:38 AM
DAMERA NIKHIL
- 1
to give space
14th Oct 2016, 7:42 PM
Jai Arora