Why is it that in Java, a superclass’ protected members are inaccessible by an indirect subclass in a different package? I know that a direct subclass in a different package can access the superclass’ protected members. I thought any subclass can access its inherited protected members.
EDIT
Sorry novice mistake, subclasses can access an indirect superclasses’ protected members.
Perhaps you’re a little confused.
Here’s my quick demo and shows an indirect subclass accessing a protected attribute:
it prints 1
As you see, the attribute
ais accessible from subclassC.If you show us the code you’re trying we can figure out where your confusion is.