【发布时间】:2019-09-27 09:30:15
【问题描述】:
我目前正在尝试使用 Class.getMethod 作为吸气剂。
我试过用这个方法:
//This works fine
Class<?> c = Class.forName("Cat");
//This is not working
Cat cat = c.getMethod("getCat");
但它不起作用。
【问题讨论】:
-
我认为
getMethod将返回Method而不是Cat... -
您正在使用反射。仅当您知道自己在做什么时才使用。
标签: java class methods reflection getter