自己写来备忘的,如有错误,请指正!
public class Demo<T> { private Class<T> clazz; public Demo() { ParameterizedType parametclass = (ParameterizedType) this.getClass().getGenericSuperclass(); Type[] actualTypeArguments = parametclass.getActualTypeArguments(); clazz = (Class<T>) actualTypeArguments[0]; } }