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());
}
}