Developers Minds - Programs Scripts Tips Solutions

Questions ? Ask for FREE !

 

Help with reflection problem in Java 

Additional Details

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?
 

Asked in Java - 121 days ago

Tags: Help with reflection problem in Java 

Answer now
Report abuse
Rate this : 0 0

Answer the QuestionsWin Cool Prizes !

Ask a Question

Ask now

Categories

Our Experts

Manohar

Manohar, Sr.Dev

Ravi Lothumalla

Ravi,  QA Lead

 

 

 

 

 

© 2011 Developers Minds - Programs Scripts Tips Solutions Ask Questions. Get Answers. All rights reserved.

eXTReMe Tracker

Search