我可以在父类中获取子属性吗?我在 PHP5 OOP 中看到可以在父类中获取子属性,但在 Java 中,我不知道。
最佳答案
如果您想要子类,look here .
然后你可以使用Reflection获取每个子类的字段和方法:
for(Class c : subclasses) {
for(Field f : c.getFields())
// Do stuff with the fields
for(Method m : c.getMethods())
// Do stuff with the methods
}
您可以查看Java API entry on Class
了解更多信息。
关于Java - 获取扩展器(子)属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9694948/