ITeye博客

String 和StringBuffer

tanzhengping11 · 2010-03-30 17:10 · corejava · 编程语言 · Markdown

String 是值传递, StringBuffer 是引用传递; public class Test1 {

/**
 * @param args
 */
public static void main(String[] args) {
	StringBuffer bs=new StringBuffer();
	test(bs);
	test1(bs);
	System.out.println(bs.toString());
}

public static void test(StringBuffer bs)
{
	bs.append("a");
	
}
public static void test1(StringBuffer bs)
{
	bs.append("a");
	
}

}

结果是aa

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。