我正在阅读 Map.Entry
接口(interface)时,我注意到它是一个 static
接口(interface)。我不太明白什么是静态接口(interface),它与常规接口(interface)有什么不同?
public static interface Map.Entry<K,V>
这是接口(interface)的定义。此处的文档:Map.Entry<K,V> .
最佳答案
I'm curious about the case when it's not an inner interface.
static
修饰符只允许在嵌套类或接口(interface)上使用。在您的示例中, Entry
嵌套在 Map
接口(interface)内。
对于接口(interface),static
修饰符实际上是可选的。这种区别对接口(interface)没有意义,因为它们不包含任何可以访问外部 this
的代码。
关于java - java中的静态接口(interface)是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8374646/