### Question:
EuclideanDistanceFn implements DistanceFn<double[]> { @Override public double applyAsDouble(double[] t1, double[] t2) { int length = t1.length; Preconditions.checkArgument(length == t2.length); double sumSq = 0.0; for (int i = 0; i < length; i++) { double diff = t1[i] - t2[i]; sumSq += diff * diff; } return Math.sqrt(sumSq); }  @Override double applyAsDouble(double[] t1, double[] t2);  }### Answer:
@Test public void testDistance() { assertEquals(Math.sqrt(14.0), new EuclideanDistanceFn().applyAsDouble(new double[] { 1.0, 2.0, 3.0 }, new double[] { 0.0, 4.0, 6.0 })); assertEquals(Math.sqrt(2.0), new EuclideanDistanceFn().applyAsDouble(new double[] { 0.0, 1.0 }, new double[] { -1.0, 0.0 })); assertEquals(0.0, new EuclideanDistanceFn().applyAsDouble(new double[] { 1.0 }, new double[] { 1.0 })); }