为什么将接口声明为抽象? [英] Why declare an interface as abstract?

查看:166
本文介绍了为什么将接口声明为抽象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将接口声明为抽象是什么意思?接口方法也是如此。有没有意义呢?

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代码库?

这是 JLS 必须说:

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 not be used in new programs.

9.4抽象方法声明:

为了与旧版本的Java平台兼容,允许使用
作为样式,为接口中声明的方法冗余地指定抽象修饰符

9.4 Abstract Method Declarations:
For compatibility with older versions of the Java platform, it is permitted but discouraged, as a matter of style, to redundantly specify the abstract modifier for methods declared in interfaces.

这篇关于为什么将接口声明为抽象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆