//这两个题目是为了搞清楚形参和实参的关系
public class Foot{
public static void main(String[] args){
StringBuffer a = new StringBuffer("A");
StringBuffer b = new StringBuffer("B");
operate(a,b);
System.out.println(a+","+b);
Integer i = new Integer(0);
add3(i);
System.out.println(i.intValue());
}
public static void add3(Integer i){
int val = i.intValue();
val += 3;
i = new Integer(val);
}
static void operate(StringBuffer x, StringBuffer y){
x.append(y);
//System.out.println(y);
y = x;
// System.out.println(y);
}
}
我通过上边的两个小例子,对形参和实参又有了进一步的理解 |