java force an extending class

前端 未结 6 1353
梦毁少年i
梦毁少年i 2020-12-31 00:17

In Java, can I somehow force a class that extends an abstract class to implement its constructor with a Object as a parameter?

Something like

public          


        
6条回答
  •  猫巷女王i
    2020-12-31 00:54

    If you add a public Points(Object o) {} constructor to Points, you force any subclass constructors to call that super constructor. However I don't think there's no way of ensuring that subclasses use that exact constructor signature.

提交回复
热议问题