All pastes #2131130 Raw Edit

Anonymous

public text v1 · immutable
#2131130 ·published 2012-03-22 15:41 UTC
rendered paste body
public class F {
    public static class A {
        int methodA() {
            return 7;
        }
    }
    public static interface I {
        int methodI();
    }

    private static class B extends A implements I {
        public int methodI() {
            return 12;
        }
    }

    private static class C extends A implements I {
        public int methodI() {
            return 17;
        }
    }

    public static <T extends A & I> T newThing() {
        return (T) new B();
    }

    public static void main(String... _) {
        A $a = F.<C>newThing();
        I $i = F.<C>newThing();
        System.out.println($a.methodA());
        System.out.println($i.methodI());
    }
}