dpp dpp - 27 days ago 12
Java Question

Why doesn't Java allow private members in interface?

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

Answer

From the Java Language Spec, (Access Control):

"The Java programming language provides mechanisms for access control, to prevent the users of a package or class from depending on unnecessary details of the implementation of that package or class."

Access control is all about hiding implementation details. An interface has no implementation to hide.

Comments