• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String buffer

 
Archana Agrawal
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all,

public class TestBuffer {
public void myBuf( StringBuffer s, StringBuffer s1) {
s.append(" how are you") ;
s = s1;
System.out.println("s in mybuf block is " +s);
}
public static void main ( String args[] ) {
TestBuffer tb = new TestBuffer();
StringBuffer s = new StringBuffer("Hello");
StringBuffer s1 = new StringBuffer("doing");
tb.myBuf(s, s1);
System.out.print("s is main block is : " +s);
}
}
The output is:-
s in mybuf block is doing.
s is main block is : Hello how are you.
So now, my question is that in mybuf method the value of s is changed to doing,then how i am getting the output as "Hello how are you" in main block,
please help,
thanks in advance.........
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic