Tôi không thể hiểu tại sao method2 không biên dịch trong khi method1 biên dịch. Tôi đang sử dụng Eclipse với JavaSE 1,7 và tôi đã nhận lỗi sau trên method2:Tại sao <T mở rộng Enum <T> & SomeInterface> biên dịch, nhưng không <T mở rộng 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;
}
}
bị đánh đập bởi giây. * Skeet! * \ * Lắc nắm tay * – Radiodef