What is the use of creating a constructor for an abstract class in Java?

前端 未结 8 2064
时光取名叫无心
时光取名叫无心 2020-12-03 18:50

I would like to know what purpose a constructor for an abstract class serves; as we do not instantiate abstract classes, why would we ever need such a constructor?

8条回答
  •  失恋的感觉
    2020-12-03 19:16

    I agree, Constructors are created assuming there will be instances. If you have lot of common code you can think of creating a Constructor but it is much better to put it in a init() method.

提交回复
热议问题