更新时间:2022-12-04 18:49:49
据我了解接口(我的实验已经加强了),没有任何目的让父母和孩子都实现相同的界面。
没有。从技术上讲,这是完全多余的。
No. Technically, it is completely redundant.
它 然而记录了你想要的事实 SoapFacadeImpl
是一个 SoapFacade
并确保你得到编译错误,如果你(或其他人)决定删除实现SoapFacade $来自基类的c $ c>。
It does however document the fact that you intend SoapFacadeImpl
to be a SoapFacade
and it ensures that you get a compile error, if you (or someone else) decides to remove implements SoapFacade
from the base class.
您可以在标准Java Collections API中的任何位置看到此模式。 ArrayList
实现 List
,即使它的基类( AbstractList
)已经,确实如此。同样适用于 HashSet
/ AbstractSet
和 Set
界面。
You see this pattern everywhere in the standard Java Collections API. ArrayList
implements List
even though its base class (AbstractList
) already, does. Same holds for HashSet
/ AbstractSet
and the Set
interface.