I need to know whether this is possible first of all. I have object which is populated with data. I need to do some operations on few fields present in the object. The fields that need to be operated is decided dynamically by reading from an XML file. So how can get an value by only having the field name.
Thanks in Advance.
Jeroen T Wenting
posted 11 years ago
Class.getField(String) or Class.getDeclaredField(String) are your friends. Of course visibility rules apply.
If the class follow standard JavaBeans naming convention for fields, you can turn the name into the name of an accessor method easily and use Class.getMethod(String, Class) instead.