public class Example { /**
* @param args
*/
String str=new String("good");
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 ");
System.out.print(ex.ch);
}
public void change(String str,char ch[]){
str="test ok";
ch[0]='g';}}
str在change函数外部(域范围外)值不会改变。
ch[]是地址传递,只要有一处改变,因为地址值变化了,所以在change函数外ch[]的值也跟着变化
而char[]显然不在此列,所以值改变了