code: public long distance2(int[] point1, int[] point2) throws Exception {
      if (point1.length == point2.length) {
        long sum = 0;
        for (int i = 0; i < point1.length; i++) {
          sum = sum + (point2[i] - point1[i]) * (point2[i] - point1[i]);
        }
        return sum;
      }
      else {
        throw new Exception("Exception in Euclidean distance: array lengths are not equal");
      }
    }
docs: Calculates the square of the Euclidean distance between two multidimensional points represented
  by integer vectors.
  
  @param point1 The first point.
  @param point2 The second point.
  @return The Euclidean distance.
  @throws Exception In the case of error.