lundi 17 août 2015

retrieve field of type class

I have a class that is going to be passed into a function and it will be defined as follows:

class ayy{

String blah;
Class a;
Class b;

}

I want to be able to invoke the getSimpleName() method on the classes a and b. Currently I am doing it as follows:

Class c = (Class)argument; // Where argument is the "ayy" class
c.getField("a").getSimpleName();

But this gives me an error saying "getSimpleName()" is not defined for type field.





Aucun commentaire:

Enregistrer un commentaire