Why doesn't Java allow private members in interface?

后端 未结 13 1370
时光取名叫无心
时光取名叫无心 2020-12-07 13:11

Why doesn\'t Java allow private members in interface? Is there any particular reason?

13条回答
  •  星月不相逢
    2020-12-07 13:44

    Private interface methods are part of Java 9 as part of JEP-213. Since interfaces in Java 8 can have default methods, private methods allow for multiple default methods to use a shared private method.

提交回复
热议问题