I can't understand why the method2 does not compile whereas method1 does compile. I am using Eclipse with JavaSE 1.7 and I got the following error on method2:
Multiple markers at this line
The type Enum<T> is not an interface; it cannot be specified as a bounded parameter
Bound mismatch: The type T is not a valid substitute for the bounded parameter <E extends Enum<E>> of the type Enum<E>
public class Test {
public interface SomeInterface {
}
public static <T extends Enum<T> & SomeInterface> T method1() {
return null;
}
public static <T extends SomeInterface & Enum<T>> T method2() {
return null;
}
}