public class Test01 {
String str="good";
char[] chr={'a','b','c'};
Data data=new Data("data");
public static void main(String[] args) {
Test01 t1=new Test01();
t1.exchange(t1.data, t1.str, t1.chr);
System.out.print(t1.data.getData()+","+t1.str+",");
System.out.println(t1.chr);
}
public void exchange(Data d,String str,char[] chr){
d=new Data("newdata");
str="news";
chr[0]='g';
}
}
class Data{
private String data;
public Data(String data){
this.data=data;
}
public void setData(String data) {
this.data = data;
}
public String getData() {
return data;
}
}
求输出。
我能明白String的输出是什么,自定义的类和字符数组的输出是什么原理呢?请大神们不吝赐教,在此谢过了。
String str="good";
char[] chr={'a','b','c'};
Data data=new Data("data");
public static void main(String[] args) {
Test01 t1=new Test01();
t1.exchange(t1.data, t1.str, t1.chr);
System.out.print(t1.data.getData()+","+t1.str+",");
System.out.println(t1.chr);
}
public void exchange(Data d,String str,char[] chr){
d=new Data("newdata");
str="news";
chr[0]='g';
}
}
class Data{
private String data;
public Data(String data){
this.data=data;
}
public void setData(String data) {
this.data = data;
}
public String getData() {
return data;
}
}
求输出。
我能明白String的输出是什么,自定义的类和字符数组的输出是什么原理呢?请大神们不吝赐教,在此谢过了。