What is a static interface in java?

后端 未结 3 734
执笔经年
执笔经年 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:43

    I'm curious about the case when it's not an inner interface.

    The static modifier is only allowed on a nested classes or interfaces. In your example Entry is nested inside the Map interface.

    For interfaces, the static modifier is actually optional. The distinction makes no sense for interfaces since they contain no code that could access the outer this anyway.

提交回复
热议问题