Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
考虑以下代码:
class MyClass<T>{ public void method(){ new T();//Compile error } }
是否存在可以将类型参数与特定类型匹配的代码示例?导致此错误的原因是在编译时检查的类型编译器不将类型参数T与特定类型匹配。我知道我们可以应用反射 API 来创建T.
T