public class Example {
String str = "hello,java";
char[] ch ={'a','b','c'};
public void change(String str,char ch[]){
str = "test ok";
ch[0]='G';
}
public static void main(String[] args){
Example ex = new Example();
ex.change(ex.str,ex.ch);
System.out.println(ex.str+"....");
System.out.println(ex.ch);
请问,为什么结果 ex.ch变成了GBA而ex.str却还是 "hello,java"呢?
打印结果是
hello,java....
Gbc |