Java – you can mark interfaces, such as serializable, which contains default methods?

I don't think it can, because the principle of markup interface is that there is no method, but I don't know because the default method is not abstract

Solution

Like Java, the "marker" interface is just a regular interface Therefore, it can have the same default method as any (Java - 8) interface

Now, I have to say yes about whether this violates the principles of the marker interface The tag interface should be used as a flag to identify only one class and comply with some external standards It can now be a marker interface with abstract / default methods, but it will no longer be purely defined

From valid Java (Second Edition):

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>