Is there a way to make sure classes implementing an Interface implement static methods?

后端 未结 9 2004
礼貌的吻别
礼貌的吻别 2021-01-07 17:11

First of all, I read erickson\'s useful reply to \"Why can’t I define a static method in a Java interface?\". This question is not about the \"why\" but about the \"how then

9条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-07 18:05

    One solution - is make all methods non-static with requirement that class must have default constructor. Then you can instantiate it easily and call methods you need.

提交回复
热议问题