How to get around the lack of abstract fields in Java?

前端 未结 5 2039
遇见更好的自我
遇见更好的自我 2021-01-13 01:06

Assume, we have an abstract class A and we want to force all subclasses to have a certain field. This is not possible in Java, because we can not define abstrac

5条回答
  •  执念已碎
    2021-01-13 01:58

    The abstract method is probably the most object oriented.

    If you have too many fields, you may want to regroup those in a POJO (if a new concept is appropriate).

提交回复
热议问题