为什么将接口声明为抽象接口?

编程入门 行业动态 更新时间:2024-10-23 18:27:50
本文介绍了为什么将接口声明为抽象接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

例如

公共抽象接口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.

更多推荐

为什么将接口声明为抽象接口?

本文发布于:2023-06-07 15:23:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/568566.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:接口   抽象   声明

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!