code: public static double squaredDistance(int[] x, int[] y) {
          if (x.length != y.length) {
              throw new IllegalArgumentException("Input vector sizes are different.");
          }
  
          double sum = 0.0;
          for (int i = 0; i < x.length; i++) {
              sum += sqr(x[i] - y[i]);
          }
  
          return sum;
      }
docs: The squared Euclidean distance.