code: public static double kendall(int[] x, int[] y) {
          if (x.length != y.length) {
              throw new IllegalArgumentException("Input vector sizes are different.");
          }
  
          int is = 0, n2 = 0, n1 = 0, n = x.length;
          double aa, a2, a1;
          for (int j = 0; j < n - 1; j++) {
              for (int k = j + 1; k < n; k++) {
                  a1 = x[j] - x[k];
                  a2 = y[j] - y[k];
                  aa = a1 * a2;
                  if (aa != 0.0) {
                      ++n1;
                      ++n2;
                      if (aa > 0) {
                          ++is;
                      } else {
                          --is;
                      }
  
                  } else {
                      if (a1 != 0.0) {
                          ++n1;
                      }
                      if (a2 != 0.0) {
                          ++n2;
                      }
                  }
              }
          }
  
          double tau = is / (Math.sqrt(n1) * Math.sqrt(n2));
          return tau;
      }
docs: The Kendall Tau Rank Correlation Coefficient is used to measure the
  degree of correspondence between sets of rankings where the measures
  are not equidistant. It is used with non-parametric data.