Tim Cooke wrote:I've added a bunch of comments into your code to help explain what's going on. Matthew got in there while I was typing this out, and he's right, the source of the misunderstanding is down to the fact that to the 'operate' method you're passing a reference to an Object, not the Object itself.
Thank you for your explaination.
Still have some doubt.
1. You have written // Remember Pass by Reference means that y and a refer to the same StringBuffer...how y and a refer to same object?
2. I am confused with last assignment. y=x; If you say, y has scope only inside this method, then why append function changes y's (b's) value in original function.
Like for following code, I am clear about the pass by value concept. And Result is 10,20. But for this StringBuffer example, I am confused.