then will return as string objects reside in a pool. When ever a string object is to be created, string pool is checked for an existing object of same value, if exists the reference is assigned to existing object else a new object will be created and the reference assigned.
Wow. StringBuilder /-Buffer don't override equals? Why not? I have never tried it out, as all the collections, the String-, the Wrapper-classes, all the classes I expected to overwrite equals did, I have been sure the SB-classes will also do it. Anyway, thanks for clarifying this!
Hi Neha, Thanks for posting a question which let us know one good thing. "StringBuffer does NOT override equals() method!".
Thanks to chinnikumar for pointing out that too. I was also in the same boat as that of Sasha Ruehmkorf !
Ravi, as anil said, until and unless you invoke *new* string, the String references will be true only! Once you invoke a *new* String, whatsoever it be, a *fresh and brand new object* will be created on Heap!