corso Java 1.8 JavaSE-1.8 (jdk1.8.0_20)funzione Generics chiamata non la compilazione in Java 8 estendere più interfacce
Questa classe:
public class SimpleQuestion {
public static void main(String[] args) {
DoNothing();
DoNothing2();
DoNothing3();
DoNothing4();
}
public interface Interface1 {
public void go();
}
public interface Interface2<X> {
public X go2();
}
private static <X, T extends Interface2<X> & Interface1> void DoNothing() {
return;
}
private static <X, T extends Interface2 & Interface1> void DoNothing2() {
return;
}
private static <X, T extends Interface2<X>> void DoNothing3() {
return;
}
private static <T extends Interface2<T> & Interface1> void DoNothing4() {
return;
}
}
dà l'errore di compilazione:
Il metodo DoNothing() nel tipo SimpleQuestion non è applicabile per gli argomenti()
Wh e quell'uno e non DoNothing2,3 e 4?
Non riesce in Eclipse. Il compilatore Oracle funziona per me. Piango bug! –
Tuttavia, funziona se si forniscono esplicitamente argomenti tipo. –
Compila bene per me in Java7; probabilmente un bug nel compilatore/IDE che stai usando – Krease