UltimateCoder
01-04-2012, 04:45 PM
Being new at Java programming, please bear with me
Using reflection, I run into a problem I hope someone can help me with...
Field f = someClass.getDeclaredField("fieldName");
f.setaccessible(true);
Object fieldValue = f.get(someClass);
This is possible, but what if I don't want to use object but cast the result of f.get to a class... but this class is unknown till runtime; is that possible to do, and how should it be done?
Class x = anotherClass.newInstance();
x objectX = (x) f.get(someClass);
any help?
Using reflection, I run into a problem I hope someone can help me with...
Field f = someClass.getDeclaredField("fieldName");
f.setaccessible(true);
Object fieldValue = f.get(someClass);
This is possible, but what if I don't want to use object but cast the result of f.get to a class... but this class is unknown till runtime; is that possible to do, and how should it be done?
Class x = anotherClass.newInstance();
x objectX = (x) f.get(someClass);
any help?