求解
解决两个问题:(说明运行结果的原因)
1:public class Foo {
public static void main(String[] args) {
StringBuffer a = new StringBuffer("A");
StringBuffer b= new StringBuffer("B");
operate(a,b);
System.out.println(a+","+b);
}
static void operate(StringBuffer x ,StringBuffer y){
x.append(y);
y = x;
}
}
2:public class Test1 {
public static void add(Integer i){
int val = i.intValue();
val +=3;
i = new Integer(val);
}
public static void main(String[] args) {
Integer i = new Integer(0);
add(i);
System.out.println(i.intValue());
}
}