我对 java 中的标记接口(interface)感到困惑。
有人可以告诉我当我们在标记接口(interface)中没有方法时,然后从哪里调用它吗?我们是否也必须明确地实现这一点?
最佳答案
它就像任何其他界面一样。
并用于在运行时对对象进行类型检查。
例如:
在其他地方Runtime
实现了像
if (SomeObjImpMarkerInterface instanceof SomeMarkerInterface ) {
// Hey this object is that type
} else {
// Not that type.
}
关于java - 当java中没有方法时,标记接口(interface)有什么用以及它如何发挥作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24758881/