This question already has answers here:
What is the purpose for using an empty interface that extends another in Java?
                                
                                    (3个答案)
                                
                        
                                6年前关闭。
            
                    
没有方法的空接口有什么用?

例如:

interface One {
}

最佳答案

这些称为Marker Interfaces,它是设计模式之一。

根据接口的定义,实现这些接口的类具有特殊的行为。

例如:可以序列化实现标记接口Serializable的类。

现在,这些日子已被Annotations取代

关于java - 没有方法的空接口(interface)有什么用? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17334980/

10-11 22:35
查看更多