How can I achieve this?
public class GenericClass
{
public Type getMyType()
{
//How do I return the type of T?
}
}
I found this to be a simple understandable and easily explainable solution
public class GenericClass {
private Class classForT(T...t) {
return t.getClass().getComponentType();
}
public static void main(String[] args) {
GenericClass g = new GenericClass();
System.out.println(g.classForT());
System.out.println(String.class);
}
}