Using Java,I have to fetch multiple sets of values from an XML file to use in my code. It just so happens that, one of the values I retrieve is the name of a static variable(the value of which is defined in a class file.) I need to find a way to fetch the value of the static variable using the name of the variable I get from the XML file.
Help?
You can use
Class.forNameto load the class (if necessary; if you have a direct reference to it just useClassName.class), thenClass#getFieldandField#getfor that:Assuming I have this other class:
Then this:
outputs