Here you can find the source of distance(double[] p1, double[] p2)
public static double distance(double[] p1, double[] p2)
//package com.java2s; public class Main { public static double distance(double[] p1, double[] p2) { double sum = 0; for (int i = 0; i < p1.length; i++) { sum += Math.pow(p1[i] - p2[i], 2); }/*from w ww . java 2s . c o m*/ return Math.sqrt(sum); } public static Double distance(Double[] p1, Double[] p2) { double sum = 0; for (int i = 0; i < p1.length; i++) { sum += Math.pow(p1[i] - p2[i], 2); } return Math.sqrt(sum); } }