I thought when we assign value to y it would also be assigned the same value and created again.
that is the reason why x when reassigend with a new value a new string is crerated. or a new string is created only when we use the keyword "new" and updations on this would lead to a new string. correct me if i am wrong.
Thanks in advance
SCJP 5.0<br /> <br />"Skills are started with learning and mastered with improvement. Nothing is hereditary except death" BUDDHA...
hi srinivas, x is just a reference which was pointing to "xyz" string object and it is now pointing to a new string object "xyzabc". y is also a reference and is now pointing to new string object "abc". As you must be knowing ,Strings are immutable so when ever you change its value , the reference points to a new object(here in our case "xyxabc"). hope this would help you ..
Hi srinivas, I think the reason "xyzabc" as a new object is because of the the "+" operation but not the assignment operation. How do you think about it? I read the chapter in K&B, but couldn't find the page now. Anybody else can help to explain in detail? Thanks