I have some Java 8 code like the following snippet.
public class Test {
static protected <T extends Comparable<T>> T[] myFunction(T[] arr) {
// do stuff...
return arr;
}
public static void main(String[] args) {
int[] a = new int[] {1,4,25,2,5,16};
System.out.println(Arrays.toString(myFunction(a)));
}
}
When I try to run it, I get the error below:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method myFunction(T[]) in the type LottoResult is not applicable for the arguments (int[])
Why does this happen and how do I have to rewrite it to be able to also pass int[] arrays to myFunction?