samedi 16 juillet 2016

Find the class of a field using reflection

We can use:

Class.getFields();

to find all fields listed by the enclosing class. I would like to do the reverse. Consider:

class x {
    Object sd = new Object();
}

Is there a way to do something like:

sd.getSomethingClass();

and return x?





Aucun commentaire:

Enregistrer un commentaire