lundi 20 juillet 2020

Get generic type of java.util.List

I have:

class TestClass {
  public List<Integer> integerList;
  public List<String> stringList;
  public List<List<String>> listOfStringLists;
  public List<List<Integer>> listOfIntegerLists;
}

The reflection-based proposed answer works well to get the generic parameter type of integerList (ie. Integer) or of stringList (ie. String).

Is there a similarly easy way to retrieve the generic parameters for listOfStringLists and listOfIntegerLists?





Aucun commentaire:

Enregistrer un commentaire