Why doesn't Java allow private members in interface?

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

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

13条回答
  •  青春惊慌失措
    2020-12-07 13:23

    It is because they would be useless.

    There would be no way to call a private method.

    Private members are an implementation detail. An interface is about the public role that a class can take on.

提交回复
热议问题