java对象浅克隆
java clone()不具备传递性。
如 Student extends Person {}
Student stu1 = newStudent(),Student stu2= stu1.clone();
此时使用了stu1的clone()方法,需在Student中重写clone()方法,如在Person中重写了clone()方法,而在Student中未重写clone()方法,则上面的stu1.clone()使用依旧会报错。
以此记录clone()方法不具备继承传递性。
...
原创
2021-10-20 10:42:06 ·
72 阅读 ·
0 评论