jeudi 7 mai 2015

Unable to get Class object from generic Type [duplicate]

This question already has an answer here:

I have following method and want to access Class object of generic T class such as String.class, I mean why T.class does not give class object.

public class GenericClass<T>{

 public void map(T object){

 //Field[] fields = T.class.getFields();  // not corrent statement
 Field[] fields = object.getClass().getFields();

 }

}





Aucun commentaire:

Enregistrer un commentaire