Is it possible to call a method by reflection from a class?
class MyObject {
... //some methods
public void fce() {
//call another method of this object via reflection?
}
}
Thank you.
Is it possible to call a method by reflection from a class?
class MyObject {
... //some methods
public void fce() {
//call another method of this object via reflection?
}
}
Thank you.
You can.. But there's are probably better ways to do what you're after (?). To call a method via reflection you could do something like -
If the method you want to invoke has arguments then it's slightly different - you need to pass arguments to the invoke method in addition to the object to invoke it on, and when you get the method from the Class you need to specify a list of argument types. i.e. String.class etc.
Absolutely:
If you have problems, post a specific question (preferrably with a short but complete program demonstrating the problem) and we'll try to sort it out.