【发布时间】:2017-05-08 18:39:40
【问题描述】:
所以在课堂上(ImportantClass123)我有这个:
public AnotherImportantClass aReallyImportantClass;
如何退货
AnotherImportantClass
通过了解它的字段名称:
aReallyImportantClass
有点像
ImportantClass123.getFieldWithName("aReallyImportantClass");
?
如何编写 getFieldWithName?它的返回类型是什么?上课?
【问题讨论】:
-
你需要像反射 api 这样的东西,read this
-
@shmosel OP 正在寻找字段的类型,而不是值。令人惊讶的是,我找不到那个副本。
-
@ErwinBolwidt 是的,我错过了。