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的过去。


  • 相关阅读:
    海选女主角
    发工资咯:)
    绝对值排序
    数列有序!
    母牛的故事
    一文看懂外汇风险准备金率调整为 20%的含义
    1080i减少带宽
    为什么要采用隔行扫描?
    720P、1080P、4K是什么意思?
    VBR一次編碼 v.s 二次編碼(VBR 1-pass vs 2-pass)
  • 原文地址:https://www.cnblogs.com/rainisic/p/2344041.html
Copyright © 2011-2022 走看看