你可以这么写:
class BodyImpl implements Body{
//do something
public static void main(String[] args) {
Type[] interfaces = BodyImpl.class.getInterfaces();
ParameterizedType firstInterface = (ParameterizedType) interfaces[0];
Class c = (Class) firstInterface.getActualTypeArguments()[0];
System.out.println(c.getName()); // prints "AtomEntry"
}
}
就得到你所要的接口参数了!
Java反射-属性操作