I wrote this code
<T> T [] reverse(T [] arr) {
for(int i = 0 ; i < arr.length / 2; i++) {
T buf = arr[i];
arr[i] = arr[arr.length - i - 1];
arr[arr.length - i - 1] = buf;
}
return arr;
}
But when I pass an array with primitive type like that
int [] arr = {0,1,2,3};
the console return method reverse in class Rope cannot be applied to given types;
When I write the method directly in Processing
the array of int
is accepted, but when I implement my function in my library java, that's don't work.
I'll suppose there is a solution to deal between int
and Integer
but how ?