我在做作业是出现了一个Person (Person p)的一行代码,并不理解什么意思,求解答
这个方式也是一个构造方法,用一个Person对象创建新对象
构造方法,参数类型为Person
例:
Person p = new Person("name", true);
Person p0 = new Person(p);
.....
class Student{
private String name;
private String sex;
}
Person(Student student){
this.name = student.name;
this.sex = student.sex;
};
Person(Person p) {
this.name = p.name;
this.sex = p.sex;
}