且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么Interface不能有受保护的方法

更新时间:2021-10-26 01:00:15

受保护的方法用于共享实现 with subclasses。就实现共享而言,接口没有任何提供,因为它们根本没有实现。因此,接口上的所有方法都必须是公共的。

Protected methods are intended for sharing implementation with subclasses. Interfaces have nothing to offer as far as implementation sharing goes, because they have no implementation at all. Therefore all methods on interfaces must be public.