问题描述
将接口声明为抽象是什么意思?接口方法也是如此。有没有意义呢?
What's point of declaring an interface as abstract? Same thing for an interface method. Is there a point to it?
例如。
public abstract interface Presenter {
public abstract void go(final HasWidgets container);
}
推荐答案
你在哪里遇到过您发布的代码块,任何旧的Java代码库?
这是必须说:
Where did you come across the chunk of code you have posted, any old java code base ?
This is what the JLS has to say :
9.1.1.1抽象接口:
每个接口都是隐式抽象的。此修饰符已过时,不应在新程序中使用
。
9.1.1.1 abstract Interfaces:
Every interface is implicitly abstract. This modifier is obsolete and should notbe used in new programs.
9.4抽象方法声明:
为了与旧版本的Java平台兼容,允许使用
作为样式,为接口中声明的方法冗余地指定抽象修饰符
。
9.4 Abstract Method Declarations:
For compatibility with older versions of the Java platform, it is permitted butdiscouraged, as a matter of style, to redundantly specify the abstract modifierfor methods declared in interfaces.
这篇关于为什么将接口声明为抽象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!