标签:style blog color ar sp div c log amp
public class Example { String str = new String("good"); static StringBuffer sbf=new StringBuffer(); char[] ch = {‘a‘,‘b‘,‘c‘}; public static void main(String[] args) { Example ex = new Example(); ex.change(ex.str, ex.ch); System.out.print(ex.str +"and"); //string是不变的,goodand System.out.print(ex.ch);//gbc //参考答案输出结果:goodandgbc change2(sbf); System.out.println(sbf); //sbf改变了 } public void change(String str, char ch[]){ str= "test ok"; ch[0]= ‘g‘; } public static void change2(StringBuffer sbf) { sbf.append("333"); } }
标签:style blog color ar sp div c log amp
原文地址:http://www.cnblogs.com/hansongjiang/p/3997236.html