I would like to create an array containing static methods (or containing references to static methods). I have tried to create an array of classes which implement an interface with the method. With this method, I would get the object and then call the method on it. This does not work for static methods. Is there a way of doing it in Java?
EDIT: Here is the method I have used so far:
interface TableElement{
public Integer lookup(int value);
}
TableElement[] table = new TableElement[]
{
new TableElement() { public Integer lookup(int value) { return 0; } },
new TableElement() { public Integer lookup(int value) { return value * 3; } },
new TableElement() { public Integer lookup(int value) { return value * value + 3; } },
};
public Integer find(int i, int value) {
return table[i].lookup(value);
}
I would like the find method to be static.