mercredi 29 avril 2015

How to get generic field type (string representation) with help reflection - Java?

There are some fields:

public class Class1 {
    private Map<String,Integer> field1 = new HashMap<String,Integer>();
    private int someField = 1;
    private int[] myIntArray = new int[]{1,2,3};
    private List<ArrayList<String>> words = null;
    private ArrayList<String>[] group = (ArrayList<String>[])new ArrayList[4];
    private List<List<List<ArrayList<List<List<String>>>>>> lists = null;
}

Is there a simple way to get string representation of each of these (and generally any) types?





Aucun commentaire:

Enregistrer un commentaire