本文介绍了为什么嵌套接口隐式声明为静态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正如标题所说,为什么嵌套接口是隐式静态的。为什么我不能像嵌套类一样使用嵌套接口,例如静态和无静态
解决方案
从:
ie它保持对其封闭实例的引用。
另一个接口,它只是类型的静态定义。一个契约,用于提供一些多态性。
接口本身不能被实例化,因此它不能具有状态,因此它无法知道封闭的实例。 / p>
as the title says, why nested interfaces are implicitly static.Why cant i use nested interfaces just like nested classes ie like with static and without static
解决方案
From the oracle documentation:
i.e. it maintains a reference to its enclosing instance.
An interface on the other and is just a static definition of type. A contract, used to provide some polymorphism.
An interface cannot itself be instantiated, therefor it cannot have state, and thus it cannot "know" about an enclosing instance.
这篇关于为什么嵌套接口隐式声明为静态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!