I need to retrieve value of a final static string in an interface. I don't know the interface name till run time. I cannot load the interface because no class implements the interface. Would you give me some suggestion? Thanks
Despite its name, the Class class can represent interfaces as well as classes. So use <pre> Class cl = Class.forName(interfaceName); Field fld = cl.getField(fieldName); String value = fld.get(null).toString(); </pre>
Thanks for your reply. It works like a charm. I thought I need to have an empty constructor to load a class. Since interface does not contain any implementing method, I may need a class that implement this interface. After revisiting the API, it does clarify my confusion. Thanks a lot Jim Joey
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards