title: How can I pass a comparison function into a Java method?
body: <p>I'm porting some code from Python to Java 8 and am stuck on a method where one of the parameters is a matrix and the others is a comparison function, which in Python is something like <code>np.gt</code> or <code>np.lt</code>.</p>
  
  <p>I'm finding this difficult to implement in Java, as Java comparisons (Comparator) only operate on complex types, and autoboxing doesn't seem to work.</p>
  
  <p>What I'd like to write is:</p>
  
  <pre><code>public static boolean[][] matrix_check(double[][] matrix, Comparator&lt;double&gt; comparator) {
      // ...
  }
  </code></pre>
  
  <p>But <code>Comparator&lt;double&gt;</code> obviously doesn't work. How should I implement this functionality in Java?</p>