What is a static interface in java?

后端 未结 3 733
执笔经年
执笔经年 2020-12-02 20:00

I was reading through the Map.Entry interface, when I noticed it is a static interface. I didn\'t quite understand what a static interface is, and

3条回答
  •  天命终不由人
    2020-12-02 20:42

    Static inner interface and inner interface is the same, all access rules are the same as with inner static class. So inner interface can be accessible only if you have access to its parent class/interface. In case below you will have access to interface B only from package of interface A, because A has default access modifier. BTW: interface B could be static or not.

     interface A {
        void testA();
        public interface B {
            void testB();
        }
     } 
    

提交回复
热议问题