不知道的标题声明的对象本身,但这里有云:使用反射
我有打算一个类来进行扩展,如:
public class A{
public void methodThatDoesStuff(){
//Uses AA here
}
protected class AA{
//does most of the stuff here
}
}
public class B extends A{
public class BB extends AA{
}
}
正如你所看到的。 methodThatDoesStuff使用AA,但是当B被调用时,我希望它使用BB来代替。
原因是AA具有一些变量,这些变量对所有类都是通用的。但有些不同。 innerClasses是具有@Expose变量,setter和getter的JSONObjects。
如何在超类中指定要使用的类?
这感觉就像一个[XY问题](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)。你真的想做什么?定义一个'AA'接口,并在'A'中放入一个需要它的单独的arg构造函数? –
你说得对,我会改变这个问题 –
究竟是什么取代'在这里使用AA'? – sp00m