开发者

Static member class cannot implement an interface

开发者 https://www.devze.com 2023-02-10 02:07 出处:网络
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:

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

精彩评论

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