So im learning on how to use Lambda in Java and got the problem, that Sonar Lint is saying i should refactor the code to use the more specialised functional interface.
public float durchschnitt(float zahl1, float zahl2) {
BiFunction<Float, Float, Float> function = (Float ersteZahl, Float zweiteZahl) -> (ersteZahl + zweiteZahl) / 2;
// ^
// Here I get the warning:
// SonarLint: Refactor this code to use the more specialised Functional Interface 'BinaryOperator<Float>'
return function.apply(zahl1, zahl2);
}
All this little program should do is calculate the average of the two floats. The programm's working fine, but I want the warning to be gone. So how can I avoid that waring and fix the code?
Edit: I oc tried finding a solution on google etc., but found none.