我想声明一个由 getParameterTypes() 返回的类型的变量,但我得到一个错误。对于 getTypeParameters() “无法解析为类型”,我也遇到了同样的错误。如何才能做到这一点?
Class<?> lcSeqHolder = null;
TypeVariable<Method> lcTypeHolder = null;
// Use reflection to find the take method
Method[] lcMethods = mcSpecificReader.getDeclaredMethods();
for (Method lcMethod : lcMethods)
{
System.out.println(lcMethod.getName());
if (lcMethod.getName().equals(TAKE_METHOD_NAME))
{
lcSeqHolder = lcMethod.getParameterTypes()[SEQUENCE_HOLDER_ARG_INDEX];
lcTypeHolder = lcMethod.getTypeParameters()[SEQUENCE_HOLDER_ARG_INDEX];
lcSeqHolder var1; // <-- lcSeqHolder cannot be resolved to a type
lcTypeHolder var2; // <-- lcTypeHolder cannot be resolved to a type
}
}