// 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 Anonymous {
    public static interface Foo {
        public void foo();
    }
    public static interface FooBar {
        public void foo();
        public void bar(int a);
    }
    public static void m1(Foo i) {
        i.foo();
    }
    public static void m2(FooBar i) {
        i.foo();
        i.bar(1);
    }
    public static void main(String[] args) {
        final int v1 = 1;
        final int v2 = 2;
        m1(new Foo() {
            public void foo() {
                System.out.println(v1);
            }
        });
        m2(new FooBar() {
            public void foo() {
                System.out.println(v1);
            }
            public void bar(int a) {
                System.out.println(v2 + a);
            }
        });
    }
}
