public class Example {
String str = new String("good");
char[] ch = {'a', 'b', 'c'};
public static void main(String args[]) {
Example ex = new Example();
System.out.println(ex.str);
System.out.println(ex.ch);
ex.change(ex.str, ex.ch);
System.out.print(ex.str + " and ");
System.out.print(ex.ch);
}
public void change(String str, char ch[]) {
str = "test ok";
ch[0] = 'g';
}
}
为啥是str没变 ch变了 有人能详细解释一下吗 从底层讲下原理 谢谢大佬们