title: Java Integer compareTo() - why use comparison vs. subtraction?
body: <p>I've found that <code>java.lang.Integer</code> implementation of <code>compareTo</code> method looks as follows:</p>
  
  <pre><code>public int compareTo(Integer anotherInteger) {
      int thisVal = this.value;
      int anotherVal = anotherInteger.value;
      return (thisVal&lt;anotherVal ? -1 : (thisVal==anotherVal ? 0 : 1));
  }
  </code></pre>
  
  <p>The question is why use comparison instead of subtraction:</p>
  
  <pre><code>return thisVal - anotherVal;
  </code></pre>