我需要将方法返回的类型与类匹配。我怎样才能做到这一点?
public class MethodTest {
public static List<String> getStringList()
{
return null;
}
public static void main(String[] args)
{
for(Method method : MethodTest.class.getMethods())
{
Type returnType = method.getGenericReturnType();
// How can for example test if returnType is class List?
}
}
}