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.
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.
42
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
a bit of art, as a gift, that will fit in a stocking