Best way to create a child object from its parent
Which is the best way to create a child given a parent with data? Would it
be ok to have a method with all parents values on the child class as:
public class Child extends Person {
public Child(Parent p) {
this.setParentField1(p.getParentField1());
this.setParentField1(p.getParentField1());
}
}
to copy parent data ti child object?
Child child = new Child(p);
No comments:
Post a Comment