enter code herehello, everyone, can somebody explain what is my problem in this function:
public class Summer{
public <X,Y> Y[] sum(X[] inArr, Y first, SumFunction<Y,X> f, Y[] outArr){
for(int i = 0; i < inArr.length; i++){
outArr[i] = f.op(inArr[i], first); //here I have problem
first = outArr[i];
}
return outArr;
}
}
I receive an error:
The method op(Y, X) in the type SumFunction<Y,X> is not applicable for the arguments (X, Y)
I need to use this function, how can I do this, thanks for any suggestions
I think you have to call f.op(first, inArray[i]).
The op() method of SumFunction seems to take an Y as the first argument, and an X as the second.