In Java, is there a legitimate reason to call a non-final method from a class constructor?

前端 未结 5 633
北荒
北荒 2020-12-03 14:56

I recently spent quite a few minutes debugging a problem in production code that in the end turned out to be caused by a class calling an abstract method in its constructor,

5条回答
  •  鱼传尺愫
    2020-12-03 15:17

    Nice question. I vote "no" and will attempt to incorporate this into my future code. I would think it would be really bad form / risky to call an abstract method.

提交回复
热议问题