Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对java中的标记接口感到困惑。
当我们在标记接口中没有方法时,谁能告诉我,然后从哪里调用它。我们是否也必须明确地实现这一点。
它就像任何其他界面一样。
并用于在运行时对对象进行类型检查。
例如:
在其他地方Runtime实现像
Runtime
if (SomeObjImpMarkerInterface instanceof SomeMarkerInterface ) { // Hey this object is that type } else { // Not that type. }