Method return type to fulfill multiple interfaces

后端 未结 4 921
野性不改
野性不改 2021-02-05 08:30

Is it possible to specify a method which returns a object that implements two or multiple interfaces?

Say we have the following interfaces:

interface Foo         


        
4条回答
  •  深忆病人
    2021-02-05 08:38

    Another solution would be to define a new interface that extends Foo and Bar and to use that as return type.

    I would say go for this option.

提交回复
热议问题