开发者

Static member class cannot implement an interface

Can anyone explain why a static member class cannot implement an interface, unless the interfac开发者_运维问答e is a marker?


It can. For example, this compiles with no problems:

interface Foo {
    void foo();
}

class Outer {    
    static class Inner implements Foo {
        public void foo() {
        }
    }
}

I'm assuming Inner is what you mean by a "static member class" here? If not, please edit the question to provide an example.


Inner classes can implement any interface.

this link will clarifies your any doubt about inner class

http://www.oopweb.com/Java/Documents/ThinkingInJava/Volume/TIJ310.htm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜