【发布时间】:2009-07-31 17:08:13
【问题描述】:
我正在使用反射来获取类中的所有方法,如下所示:
Method[] allMethods = c.getDeclaredMethods();
之后我将遍历这些方法
for (Method m: allMethods){
//I want to find out if the return is is a parameterized type or not
m.getReturnType();
}
例如:如果我有这样的方法:
public Set<Cat> getCats();
如何使用反射找出返回类型包含Cat 作为参数化类型?
【问题讨论】:
标签: java generics reflection