Hallo allerseits,
eine generische Methode erhält als Argument ein Array und soll es ausdrucken.
Warum wird bei "drucken(w)" folgender Fehler angezeigt?
"The method drucken(T[]) in the type Test is not applicable for the arguments (int[])"
Kann das jemand erklären?
Danke + Gruß
eine generische Methode erhält als Argument ein Array und soll es ausdrucken.
Java:
public class Test {
public static void main(String[] args) {
int[] w = {1,2,3,4,5};
drucken(w); //leider Fehlermeldung
}
public static <T> void drucken(T[] a){
for (T i: a)
System.out.println(i);
}
}
"The method drucken(T[]) in the type Test is not applicable for the arguments (int[])"
Kann das jemand erklären?
Danke + Gruß
Zuletzt bearbeitet: