i've got the class P4
in the default package (i know using the default package is bad practice, but merely "for example" for now):
import temp.P2;
public class P4 extends P2 {
public void someMethod() {
P2 p2 = new P2();
// p2.p2default(); // ERROR as expected
p2.p2public();
p2.p2protected(); // ERROR as not expected
}
}
and class P2
in package temp
package temp;
public class P2 {
protected void p2protected() {
...
}
public void p2public() {
...
}
void p2default() {
...
}
}
From the access control mechanism, i'd expect
P4
-- having extended P2
, should be able to see the protected
member of its super class even from outside the package once it imported the namespace of that package.
What am i missing?
TIA.