I thought the answer would be HELLOTHERE,HELLOTHERE but sb2 is still HELLOO.
can anyone explain this.
public class Test{
public void method1(StringBuffer s1,StringBuffer s2){
s1.append("THERE");
s2=s1;
}
public static void main(
String arg[]){
StringBuffer sb1=new StringBuffer("HELLO");
StringBuffer sb2=new StringBuffer("HELLOO");
Test t=new Test();
t.method1(sb1,sb2);
System.out.println("sb1 is"+sb1+"sb2 is"+sb2);
}}
answer is HELLOTHERE,HELLOO
Thanks in advance.