Why can a protected interface from a superclass in another package not be implemented in Java/Android? When the parent and the child are in the same package the code below will work. A short explanation is given below:
Parent.java
package package.example;
public class Parent {
protected interface MyInterface {
void method();
}
protected void protectedMethod() {
}
}
Child.java
package package.example.child;
import package.example.Parent;
public class Child extends Parent implements Parent.MyInterface { //not possible
@Override
public void method() {
}
@Override
public void protectedMethod() {
//This works
}
}
The above code will give the warning: 'package.example.Parent.MyInterface' has protected access in 'package.example.Parent'. Can someone explain to me why this is not possible?