How can I print the type of a generic java type?
Reflection? Any tricks?
public class Foo<K> { private K element; @Override public String toString() { return "Type: " + K; } }
Answer
element.getClass().getSimpleName()
will probably do what you are expecting.