| Author |
accessing methods of another class
|
kourosh parsa
Greenhorn
Joined: Jan 22, 2012
Posts: 19
|
|
Hi. Here is the general structure if my code:
The problem is that my constructor needs the parameter "Board" which is the handle to the other class, but I cannot pass the parameter in claz.newInstance()
You see that I want to load classes dynamically where the class name is known at run time.
Any ideas what to do about this?
|
 |
kourosh parsa
Greenhorn
Joined: Jan 22, 2012
Posts: 19
|
|
well, I figured out that I can use
Element elm = (Element) claz.getDeclaredConstructor(Board.class).newInstance(this);
instead of
Element elm = (Element) claz.newInstance();
which works fine, but still if anyone has a better proposal, please let share it. Thanks
|
 |
 |
|
|
subject: accessing methods of another class
|
|
|