generic class signature allows to extends the same interface multiple times. Ideally it should throw compile time here. Please find the below code. It compiles successfully. But I think it shouldn't compile it. Class B signature allows to extends the MyInterface<E> twice. //-- Code start here -- //Test1.java import java.lang.reflect.*; public class Test1 { public static void main(String[] args) { B b = new B<Sun1>(); } } class D { } interface MyInterface<E> { public String foo(); } class MyClass { } class Sun1 extends MyClass implements MyInterface<Sun1>, MyInterface<Sun1> { public String foo() { return "test"; } } class B < E extends MyClass & MyInterface<E> & MyInterface<E> > extends D { } //-- code end here
|