samedi 28 novembre 2015

Get Value from java.lang.reflect.Field Object Without Knowing Original Object

I have a program which turns a .class file into a Class object. I then extract every field from the Class object with getFields(). I iterate through each field, and I want to print out their value. I know I can use:

field.get(obj)

But I don't know what to put in the obj parameter. I didn't have the field's object originally, so how do I get the field's value?

Thanks for your help!





Aucun commentaire:

Enregistrer un commentaire