Optional method in Java Interface

前端 未结 4 2058
眼角桃花
眼角桃花 2021-01-03 20:46

I have an interface with several method definitions, and I would not like to require some of them.

Is this possible? if so, how can i implement this

4条回答
  •  难免孤独
    2021-01-03 21:16

    You can have an Abstract class that implements this interface with empty function implementations and then extend from the Abstract class

    Having said that, I would question why you need to do this. Maybe you need to split you interface into multiple smaller ones and implement the only ones that you need for a class

提交回复
热议问题