[algogeeks] chanege in immutable string

2011-08-26 Thread tech coder
in java a tring object is immutable but in following code String s=java; s+=c c++; System.out.print(s); the output is javac c++ why this is so -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] chanege in immutable string

2011-08-26 Thread Prem Krishna Chettri
Its true that in Java String are immutable. Even in the code given its immutable.. Its actually the code executed like this.. String s=java; // S holds to java. s+=c c++; // Here S = S + c c++ Java + c c++ which is now assigned to the new variable which here is s itself.

Re: [algogeeks] chanege in immutable string

2011-08-26 Thread siddharam suresh
as per my knowledge, in java String s=java; // S holds to java. s+=c c++; // now s is pointing to string javac c++ not the appended string (java+c c++) // strcat and append syntactically(o/p strings) are same but wrt to memory they differ Thank you, Siddharam On Fri, Aug 26, 2011 at

Re: [algogeeks] chanege in immutable string

2011-08-26 Thread Neha Singh
@tech coder: When u execute : s+=c c++; a new string object is created with the value of s appended with c c++. Now s is made to hold the reference of this new string object. Thus the older string object is not modified, but a new string string object is created. -- You received this message

Re: [algogeeks] chanege in immutable string

2011-08-26 Thread tech coder
thanks to all got it On Fri, Aug 26, 2011 at 4:54 AM, Neha Singh neha.ndelhi.1...@gmail.comwrote: @tech coder: When u execute : s+=c c++; a new string object is created with the value of s appended with c c++. Now s is made to hold the reference of this new string object. Thus the older