0

I would think this is easily googleable question, but I found nothing. In the following code:

public class ParentClass {
    public static interface InterfaceStatic {

    }
    public interface InterfaceNotStatic
    {

    }
}

Can you describe the difference between InterfaceNotStatic and InterfaceStatic? I know what the same syntax means for nested classes, but since interfaces hold no value, the purpose of static here eludes me.

Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778

2 Answers2

0

Both declarations are the same. The static modifier is redundant in this case.

A member interface is implicitly static (§9.1.1). It is permitted for the declaration of a member interface to redundantly specify the static modifier.

(quote from JLS 8.5.1. Static Member Type Declarations)

Eran
  • 387,369
  • 54
  • 702
  • 768
0

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.

SamHoque
  • 2,978
  • 2
  • 13
  • 43