且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我可以在不覆盖整个方法的情况下向继承的方法添加代码吗?

更新时间:2022-03-04 00:50:37

是的,在你的情况下,你只需要调用超级实现:

Yes, in your case you just have to call the super implementation:

@Override
public UsineOrganisme copieAUsine(){
    UsineOrganisme usine = super.copieAUsine();

    usine.setVoraciteMin(this.voraciteMin);
    usine.setVoraciteMax(this.voraciteMax);

    return usine;
}