Link to home
Start Free TrialLog in
Avatar of pdrake
pdrake

asked on

Arrays of methods

How would you implement an array of methods? I have tried getMethods() & invoke() but can't get that to work. Are there other ways of doing it?
Avatar of jpk041897
jpk041897

Both class and method are mannaged as pointer internaly, have you tried storing the value for this.method in an array of Objects?


You can make an interface with a single method:

public interface MethodInterface {
   public myMethod(String[] args);
}

and then make an array of Objects that implement the method.

MethodInterface[] methodArray = new MethodInterface[10];

Take a look at:

http://www.panix.com/~rangerx/packages.html

it has a class library that will probably help a lot.

Let me know if it solves your problem.
ASKER CERTIFIED SOLUTION
Avatar of hosseinakhlaghpour
hosseinakhlaghpour

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdrake

ASKER

This seems a little messy. While I was waiting for an answer I figured out how to implement the array of methods I needed with an interface instead of .reflect and .Class. It's probably less powerful but perfectly satisfies my requirements. Thank you.