Hi,
please c the code below.I thought answer should be "one more" will be printed twice,but output is
one more
two
Why???
Sonu
public class
Test {
public static void main(
String args[]) {
StringBuffer a = new StringBuffer("One");
StringBuffer b = new StringBuffer("Two");
Test.swap(a,b);
System.out.println("a is "+ a +"\nb is " + b);
}
static void swap (StringBuffer a, StringBuffer b) {
a.append(" more");
b=a;//what is happening over here
}
}