private static double distance(double[] p1,double[] p2){
  double sum=0.0;
  for (int i=0; i < p1.length; i++) {
    sum+=Math.pow(p2[i] - p1[i],2.0);
  }
  return Math.sqrt(sum);
}

private static double distance ( double [ ] p1 , double [ ] p2 ) { double sum = 0.0 ; for ( int i = 0 ; i < p1 . length ; i ++ ) { sum += Math . pow ( p2 [ i ] - p1 [ i ] , 2.0 ) ; } return Math . sqrt ( sum ) ; }
returns the euclidean distance between two points .
