mercredi 22 juillet 2015

What is supposed to be passed in to this method?

After looking at the Java documentation here, and reading an Oracle tutorial, as well as visiting this question here on SO, I am still dumbfounded as to what the Object argument in Field#get(Object obj) actually is.

The process that I take to get a field using Reflection is:

Field field = SomeClass.getClass().getDeclaredField("someField");
field.setAccessible(true);

Which gives the Field object. Now, to get the actual value of the field, you would use the Field#get(Object obj) method. The documentation for this method says the following about the parameter.

obj - object from which the represented field's value is to be extracted

I have no idea what the description of the parameter even means. Can someone explain to me what this argument is truly asking for?

Thanks.





Aucun commentaire:

Enregistrer un commentaire