Can anyone please explain what is the difference between below implementation of String-
1)
{
String comma=",";
return finalStr = "Hello"+comma+"Welcome"+comma+"to"+comma+"Stack"+comma+"overflow";
}
2)
{
return finalStr = "Hello,Welcome,to,Stack,overflow";
}
How many string object will be created in first (1) block, will there be only one string finalStr
which refer to memory location where Hello,Welcome,to,Stack,overflow
is stored or will it create multiple locations for each word and then once appended it will create a new memory location.