Get generic type of java.util.List

后端 未结 14 2299
广开言路
广开言路 2020-11-22 02:06

I have;

List stringList = new ArrayList();
List integerList = new ArrayList();

Is

14条回答
  •  无人共我
    2020-11-22 02:36

    For finding generic type of one field:

    ((Class)((ParameterizedType)field.getGenericType()).getActualTypeArguments()[0]).getSimpleName()
    

提交回复
热议问题