public class GenericDemo<T>
{
public Class<T> tClass;
public GenericDemo(){
ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
tClass = (Class<T>) actualTypeArguments[0];
}
}
网友评论