public class A {
private B pb;
A(){
pb=new B();
}
public B getB(){
return pb;
}
public static void main(String[] args) {
A pa=new A();
pa.pb.getC().func();
}
}
public class B {
private C pc;
B(){
pc=new C();
}
public C getC(){
return pc;
}
}
public class C {
public void func(){
System.out.println("this is func");
}
}
public class X {
public static void main(String[] args) {
A a=new A();
a.getB().getC().func();
}
}
------解决方案--------------------