Creating an instance of derived class through the base class without hardcoding

后端 未结 4 1843
说谎
说谎 2020-12-31 14:00

My problem is as follows:

I have a base class that needs to be abstract. It has several derived classes, each with their own special properties that are contained in

4条回答
  •  佛祖请我去吃肉
    2020-12-31 14:29

    You can make createNewInstanceStep1 a protected void init method that initiates this object, and call it in each subclass's constructor.

提交回复
热议问题