Discussions

General J2EE: Interface can not have protected methods, Why ?

  1. Interface can not have protected methods, Why ? (2 messages)

    Can some one please explain why I can not have protected methods in an interface. There must be a good reason. I wanted to do it badly. May be, my design is wrong. Please help.
  2. It defeats the purpose[ Go to top ]

    Interfaces exist to define functionality. Doesn't make much sence to define required functionality just to hide it. If you want to force some sort of implementation, use an abstract class with protected abstract methods.
  3. Don't make the mistake of using interfaces to enforce a pattern which you want implementation classes to use. As stated, interfaces exist purely to define *external* functionality. This is why you cannot define any constructors in interfaces as well :)