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

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

问题描述

将接口声明为抽象有什么意义?接口方法也是如此.有道理吗?

例如

公共抽象接口Presenter {public abstract void go(最终的HasWidgets容器);}

解决方案

您是从哪里看到您发布的大量代码的,任何旧的 Java 代码库?
这就是 JLS 必须说的:>

9.1.1.1 抽象接口:
每个接口都是隐式抽象的.此修饰符已过时,不应用于新程序.

9.4 抽象方法声明:
为了与旧版本的 Java 平台兼容,允许但不鼓励,作为一种风格,多余地指定抽象修饰符用于在接口中声明的方法.

What's point of declaring an interface as abstract? Same thing for an interface method. Is there a point to it?

eg.

public abstract interface Presenter {
 public abstract void go(final HasWidgets container);
}

解决方案

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 abstract Interfaces:
Every interface is implicitly abstract. This modifier is obsolete and should not be used in new programs.

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天全站免登陆