如何从超类方法中获取对子类的类的引用?
例如,
public class MySuper {
public void myMethod(){
// here i need a reference to MySub1.class or MySub2.class
// depending on the class of the instance that invoked this method
}
}
public class MySub1 extends MySuper {
public String myString;
}
public class MySub2 extends MySuper {
public int myInt;
}