问题:
I have a generics class, Foo<T> . 我有一个泛型类Foo<T> 。 In a method of Foo , I want to get the class instance of type T, but I just can't call T.class . 在Foo的方法中,我想获取类型T的类实例,但是我无法调用T.class 。
What is the preferred way to get around it using T.class ? 使用T.class绕过它的首选方法是什么?
解决方案:
参考一: https://stackoom.com/question/EQLx/如何获得泛型类型T的类实例参考二: https://oldbug.net/q/EQLx/How-to-get-a-class-instance-of-generics-type-T
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/4348251