Hi Folks,
Could you all please let me know why, the contents of stringbuffer "S1" printed
in line 3 (//3)and line 4(//4) are not same, even though the s2 has been
assigned to s1 in line 2.
I am a bit confused with this "parsing of strings/stringbuffers" , could you
please explain me.
And how come, the value assigned to S1 in "line 2" is not going to "line 4"
Thanks a lot.
class TestBuffer {
public void myBuf( StringBuffer s1, StringBuffer s2) {
s1.append(" how are you") ; // 1
s1 = s2; // 2
System.out.println("Inside myBuf method: " + s1); //3
}
public static void main ( String args[] ) {
TestBuffer tb = new TestBuffer();
StringBuffer s1 = new StringBuffer("Hello");
StringBuffer s2 = new StringBuffer("doing");
tb.myBuf(s1, s2);
System.out.print(s1); //4
}
}
Best Regards & Good Luck
Chooti Baba
[Non-text portions of this message have been removed]