java 小程序分析:参数传递

public class Test{
	public static void main (String [] ABC){
		StringBuffer a = new StringBuffer("A");
		StringBuffer b = new StringBuffer("B");
		operate(a,b);
		System.out.println(a+","+b);
	}
	public static void operate (StringBuffer x,StringBuffer y){
		x.append(y);
		y=x;
	}
}

  输出:AB,B

x.append(y)使a为“AB”

而y=x语句没有改变b的内容,java的参数传递是传值。

posted @ 2013-11-25 16:56  little white  阅读(370)  评论(0编辑  收藏  举报