I want to invoke a protected method of another instance from within a subclass of the class providing this protected method. See the following example:
public class Nano {
protected void computeSize() {
}
}
public class NanoContainer extends Nano {
protected ArrayList<Nano> children;
}
public class SomeOtherNode extends NanoContainer {
// {Nano} Overrides
protected void computeSize() {
for (Nano child: children) {
child.computeSize(); // << computeSize() has protected access in nanolay.Nano
}
}
}
javac
tells me that computeSize() has protected access in Nano
. I can't see the reason for this (I thought I was already doing this in some other code). I'd like to keep this method being protected, what can I do?
javac version "1.7.0_09"
Edit
I wanted to provide a stripped down version, but I didn't think about the fact, that the classes lie in different packages.
nanolay.Node
nanolay.NanoContainer
nanogui.SomeOtherNode
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…