0

What is the function of third + symbol in concatenate string ?

String firstName, lastName; firstName = "David"; lastName = "Williams"; System.out.println("My name is " + firstName +" "+lastName correct me if I am wrong the first + sign concatenates "My name is" with ' first name' then the second + sign does the same for 'first name' and 'last name' string what is the use of third + sign?

16th Aug 2018, 10:27 PM
Ritwik Bhattacharyya
Ritwik Bhattacharyya - avatar
5 odpowiedzi
+ 1
+ concatenates without adding spaces, so there's one added in the middle: " " String + variable + space + another variable.
16th Aug 2018, 10:31 PM
HonFu
HonFu - avatar
+ 1
If you want to take a fixed number of inputs, I would use a for loop, then append the input of each loop to some container. I could only show you in Python unfortunately. ;) But maybe someone else will jump in...
16th Aug 2018, 10:45 PM
HonFu
HonFu - avatar
0
thanks :) I have tones of things to ask. Is there any tag option here or can we connect in any other medium?
16th Aug 2018, 10:35 PM
Ritwik Bhattacharyya
Ritwik Bhattacharyya - avatar
0
like here in user input section they have shown only how to get input form user. I want to know how to write this statement...like first you specify how many input you want (2,3) after that you give the input like i1,i2 in this manner. can you tell me sensei?
16th Aug 2018, 10:39 PM
Ritwik Bhattacharyya
Ritwik Bhattacharyya - avatar
0
haha thanks for your feedback :)
16th Aug 2018, 10:48 PM
Ritwik Bhattacharyya
Ritwik Bhattacharyya - avatar