How can I achieve this?
public class GenericClass { public Type getMyType() { //How do I return the type of T? } }
Here is my trick:
public class Main { public static void main(String[] args) throws Exception { System.out.println(Main. getClazz()); } static Class getClazz(T... param) { return param.getClass().getComponentType(); } }