我不明白为什么method2不编译,而method1编译。 我使用的Eclipse与JavaSE的1.7和我的方法2以下错误:为什么<T扩展Enum <T>&SomeInterface>编译,但不是<T扩展SomeInterface&Enum <T>>?
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;
}
}
按秒殴打。 * Skeet!* \ *摇动拳头* – Radiodef