????1??????
?????????(Prototype)??????????????????????????????μ????????????????????????????????????????????????????????????????
????2?????
?????????????????????????????????????????????????????????????????????????Щ???????μ????
????3???????UML?

????4?????
????1>?????????????????
????2>??????????????????????????
????3>????????????
????5?????????
??????1??????Java?е?clone???????????????
???????????
public class Professor {
private String address;
private double salary;
public Professor(String address?? double salary) {
this.address = address;
this.salary = salary;
}
public void setAddress(String address) {
this.address = address;
}
public void setSalary(double salary) {
this.salary = salary;
}
@Override
public String toString() {
return "Professor [address=" + address + "?? salary=" + salary + "]";
}
}
public class Student implements Cloneable {
private String name;
private int age;
private Professor professor;
public Student(String name?? int age?? Professor professor) {
this.name = name;
this.age = age;
this.professor = professor;
}
@Override
public String toString() {
return "Student [name=" + name + "?? age=" + age + "?? Professor="
+ professor.toString() + "]";
}
@Override
public Object clone() {
Student student = null;
try {
// ?????????Object?е?clone???????????????????????Object?е?clone()
// ???????????????????ж??????????????????????????????????洢????С?
student = (Student) super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return student;
}