常用的对象拷贝方法有三种:
1.通过set,get方法:
//创建user类
public class User {
private String name;
private String age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String toString(){
return "name:"+name+",age:"+age;
}
}
//创建person类
public class Person {
private String name ;
private String age;
private String gender;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gend