Ahoj, narazil jsem na problem pri dedeni. Mam 2 tridy s vnitrnima tridama:
// predek
public class FooParent {
private FooParentInner fpi = new FooParentInner();
protected FooParentInner inner() {
return fpi;
}
public void print() {
System.out.println(inner().s);
}
protected static class FooParentInner {
public String s = "FooParentInner";
}
}
// potomek
public class FooChild extends FooParent {
private FooChildInner fci = new FooChildInner();
@Override
protected FooChildInner inner() {
return fci;
}
protected static class FooChildInner extends FooParentInner {
public String s = "FooChildInner";
}
}
// main metoda
public static void main(String[] args) {
FooChild f = new FooChild();
f.print();
}
Vypise se FooParentInner. Proc? Nechapu, proc se nevypise text z potomka.
Diky za rady.