I want to use Reflection to read the display function of each child class extends class Demo.
class Demo{
public abstract void display();
}
I want clazz only initialized once,please help me :D
public static void getDisplay(Class<? extends Demo> clazz) throws
InstantiationException, IllegalAccessException {
return clazz.newInstance().display();
}
Aucun commentaire:
Enregistrer un commentaire