简短答案 :您不能。
长答案 :
由于使用Java实现泛型的方式,泛型T在运行时不会保留。您仍然可以使用私有数据成员:
public class Foo<T> { private Class<T> type; public Foo(Class<T> type) { this.type = type; } }用法示例:
Foo<Integer> test = new Foo<Integer>(Integer.class);

简短答案 :您不能。
长答案 :
由于使用Java实现泛型的方式,泛型T在运行时不会保留。您仍然可以使用私有数据成员:
public class Foo<T> { private Class<T> type; public Foo(Class<T> type) { this.type = type; } }用法示例:
Foo<Integer> test = new Foo<Integer>(Integer.class);