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.
['https://Stackoverflow.com/questions/14653177', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1571830/']
Of course, you can have an array of `Method` and then you can call it using invoke, check these examples: [How do I invoke a private static method using reflection (Java)?](https://stackoverflow.com/questions/4770425/how-do-i-invoke-a-private-static-method-using-reflection-java)
If you can meet the following conditions:

1. You know all of the keys at code generation time.
2. You know all of the values (methods) at code generation time.

You can use code like this:

```
public class Table {
    public static int hash(String key) {
        /* you can use any type of key and whatever hash function is
         * appropriate; this just meant as a simple example.
         */
        return key.length();
    }

    public static Integer find(String s, int value) {
        int h = hash(s);

        switch (h) {
          case 4: // "zero"
            if (s.equals("zero"))
                return methodZero(value);

          case 6: // "triple"
            if (s.equals("triple"))
                return methodTriple(value);

          case 11: // "squarePlus3"
            if (s.equals("squarePlus3"))
                return methodSquarePlus3(value);

          default:
            throw new UnsupportedOperationException(s);
        }
    }

    private static Integer methodZero(int value) { return 0; };
    private static Integer methodTriple(int value) { return value * 3; };
    private static Integer methodSquarePlus3(int value) { return value * value + 3; };

    /**
     * Just a demo.
     */
    public static void main(String arguments[]) {
        System.out.println("Zero(5): " + find("zero", 5));
        System.out.println("Triple(5): " + find("triple", 5));
        System.out.println("SquarePlus3(5): " + find("squarePlus3", 5));
        System.out.println("boom!");
        find("missingcode", 5);
    }
}

```

If you need to relax either of the requirements I don't believe you can do everything statically.

If you want to be able to add new keys, you'll have to create a normal hash table at adding time to store them. (You can check it in the `default` code.)

If you want to be able to replace values, you'll have to use a level of indirection there, probably using `Method` objects or implementations of `Callable` (You can call these from within the body of the `methodZero` methods).