Why doesn't Java allow private members in interface?

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

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

13条回答
  •  忘掉有多难
    2020-12-07 13:24

    According to the Java programming language scope of the private members is limited to the class in which it is declared and can be accessed only by methods of that class. But inteface doesn't have a method body hence there is no use of declaring private members inside an interface.

提交回复
热议问题