Here you can find the source of distance(double[] p1, double[] p2)
public static double distance(double[] p1, double[] p2)
//package com.java2s; //License from project: Apache License public class Main { public static double distance(double[] p1, double[] p2) { int nd = p1.length; double out = 0.0; for (int d = 0; d < nd; d++) { out += (p1[d] - p2[d]) * (p1[d] - p2[d]); }/*w ww. j ava 2 s . c o m*/ return Math.sqrt(out); } }