且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是Java中使用的标志接口?

更新时间:2022-04-05 04:07:40

在早期版本的Java,标记接口​​>是的只有这样,才能申报有关类的元数据。例如,序列化的标记接口,让类的作者说,他们的课程将正确的行为时,序列化和反序列化。

In earlier versions of Java, Marker Interfaces were the only way to declare metadata about a class. For example, the Serializable Marker Interface lets the author of a class say that their class will behave correctly when serialized and deserialized.

在现代的Java,标记接口都没有的地方。他们可以通过注解,这允许非常灵活的可完全取代元数据功能。如果您对一个类的信息,而这些信息不会改变,那么注解是重新present这是一个非常有用的方式。

In modern Java, marker interfaces have no place. They can be completely replaced by Annotations, which allow for a very flexible metadata capability. If you have information about a class, and that information never changes, then annotations are a very useful way to represent it.