我有这种情况:
public abstract class ClassA{
public ClassA getClassOfSameKind(){
return this.getClass().newInstance();
}
}
public abstract class ClassB extends ClassA{
public void doSomethingSpecial(){
ClassB otherClass = (ClassB) this.getClassOfSameKind();
//do something special that only Class B can do
}
}
你会做不同的事情吗?