Rajneesh,
First thing, there's only pass by value in
java.
I'll try to visualize the process
*sb1, sb2 are constructed:
sb1 --> "Hello"
sb2 --> "Hello"
*In method1(), since s1, s2 are copies of sb1, sb2, then
sb1 --> "Hello" <-- s1<br /> sb2 --> "Hello" <-- s2<br /> *s1.append("There")<br /> sb1 --> "HelloThere" <-- s1<br /> sb2 --> "Hello" <-- s2<br /> * s2 = s1;<br />
<br /> <br /> sb2 --> "Hello"
In main, sb1 --> "HelloThere"
sb2 --> "Hello"
Hope this'll help
[This message has been edited by Son Le (edited January 16, 2001).]