How can I achieve this?
public class GenericClass { public Type getMyType() { //How do I return the type of T? } }
If you have a class like:
public class GenericClass { private T data; }
with T variable, then you can print T name:
T
System.out.println(data.getClass().getSimpleName()); // "String", "Integer", etc.