String取值
public class Example{
String str=new String("hello");
char ch[]={'d','b','c'};
public static void main(String args[]){
Example ex=new Example();
ex.change(ex.str,ex.ch);
System.out.println(ex.str+"and"+ex.ch[0]);
}
public void change(String str,char ch[]){
str ="world";
ch[0]= 'a';
}
}
结果是helloanda
为什么不是worldanda ? 难道不能通过引用改变字符窜的值吗