标签:main new public col rgs targe pre ati 传递
String 不变性以及Java 值传递和引用传递
public class Example {
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';
}
}
点击查看结果
good and gbc
标签:main new public col rgs targe pre ati 传递
原文地址:https://www.cnblogs.com/hglibin/p/10092196.html