|
Re: Protected method in an Interface
|
Posted: Nov 16, 2005 10:47 PM
|
|
But there is one way to do this. Seems I had an error in my second example, because this code does compile.
public interface PublicInterface {
public void publicMethod();
}
protected interface ProtectedInterface extends PublicInterface {
public void protectedMethod();
}
This way you can create a instance of the class implementing ProtectedInterface inside the package, but pass it as PublicInterface to whoever needs it outside the package.
The Class itself will offer potectedMethod, but as long it is handled as PublicInterface, no one will notice.
Note that I didn't test this to the end, so my whole theroy could be wrong. But I was able to compile this code.
|
|