public class Aed {
String str = new String("good");
char[] ch = {'a','b','c'};
int num = 10;
public void change(String str,char[] ch,int num){
str = "test ok";
ch[0] = 'g';
num = 20;
}
public static void main(String[] args) {
Aed a = new Aed();
a.change(a.str,a.ch, a.num);
System.out.print(a.str);
System.out.print(a.ch);
System.out.print(a.num);
}
}
public void change(String str,char[] ch,int num){
str = "test ok";
ch[0] = 'g';
num = 20;
}
改為
public void change(String str,char[] ch,int num){
this.str = "test ok";
this.ch[0] = 'g';
this.num = 20;
}