I need to pass an array as parameter into a BiFunction
.
Use case :
Calculate the Euclidean Distance of
2
coordinates given in an array.coordinate1
andcoordinate2
are an array.
The below trial, makes the intent clearer.
BiFunction<Integer, Integer, Double> euclideanDistance =
(Integer[] x, Integer[] y) -> Math.sqrt(Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2));
But the compiler complains :
incompatible types:
incompatible parameter types in lambda expression :
Expected Integer but found Integer[]