zoukankan      html  css  js  c++  java
  • 关于Abstract interface的问题。

    今天在阅读Struts 2 的 interceptor 代码时,发现里面的接口是这样写的:

    public abstract interface Interceptor extends Serializable
    {
    public abstract void destroy();

    public abstract void init();

    public abstract String intercept(ActionInvocation paramActionInvocation)
    throws Exception;
    }

    很在意为什么是 public abstract interface. 于是上网查找了一番,在StackOverflow论坛发现如下内容:

    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.

    所以证明,abstract interface 是已经过时的写法,不过正是因为这样,也让我们更深入的理解到了interface的过去。


  • 相关阅读:
    css 正方体
    鼠标放上去,不同的cursor光标类型
    文件上传用到的函数 20150205
    PHP常用正则表达式汇总
    代码练习之 登陆 PHP会话控制 session cookie
    正则表达式全部符号解释
    字典转模型
    Day11 TableView
    Day10
    Day9
  • 原文地址:https://www.cnblogs.com/rainisic/p/2344041.html
Copyright © 2011-2022 走看看