// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class ArrayOfMethods {
    public static void main(String[] args) {
        MethodContainer[] m = new MethodContainer[] { new A(), new B() };
        m[0].doSomething();
        m[1].doSomething();
    }
}

interface MethodContainer {
    public void doSomething();
}

class A implements MethodContainer {
    public void doSomething() {
        System.out.println("I am an A");
    }
}

class B implements MethodContainer {
    public void doSomething() {
        System.out.println("I am a B");
    }
}
