/ Published in: Java

This code will only work for immediate specialization not something like class B extends A.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class A<T> { Class<T> specializedClass; public A() { this.specializedClass = (Class<T>) ((ParameterizedType) this.getClass() .getGenericSuperclass()).getActualTypeArguments()[0]; } }
Comments
