| 因为String是final修饰的,最终的,而change()方法中的参数是另一个String,即是又创建了一个新的String对象,地址不同,名称也不同 public class StrChTest {
 String str="good";
 char[] ch=new char[]{'n','i','g','h','t'};
 public static void main(String[] args) {
 StrChTest sc=new StrChTest();
 sc.changed(sc.str, sc.ch);
 System.out.print(sc.changed(sc.str, sc.ch)+"````"+Arrays.toString(sc.ch));
 
 }
 public String changed(String stsr,char[] chs)
 {
 stsr="love";
 chs[0]='i';
 return stsr;
 }
 }
 改为这样就是方法里字符串的名字 了
 |