我有以下类。
public class SomeClass<T extends CustomView> {
public void someMethod() {
T t; // = new T(context) ...compile error!
// I want instance of SomeType that have parameter(context) of constructor.
t.go();
}
}
我想创建一个具有构造函数参数的泛型类型 T 实例。
我尝试了 TypeToken
、Class<T>
、newInstance
等方法,但都没有成功。我需要一些帮助。谢谢你的回答。