title: What is the advantage of having typed interface over method that receives a certain type in Java?
body: <p>I'm writing a class in Java and I want to implement <code>Comparable</code> interface. This is the class:</p>
  
  <pre><code>public class Flight implements Comparable {
      private int flightTime;
      public int compareTo(Object o) {
          Flight f = (Flight) o;
          return this.flightTime - f.flightTime;
      }
  }
  </code></pre>
  
  <p>Now I learned that we can also add type to the interface as follows:</p>
  
  <pre><code>public class Flight implements Comparable&lt;Flight&gt; {
      private int flightTime;
      public int compareTo(Flight f) {
          return this.flightTime - f.flightTime;
      }
  }
  </code></pre>
  
  <p>What are the advantages of the second implementation (please do not reduce the question to the advantages of generics in general)? </p>
  
  <p>I'm fairly new to Java and I suspect that there must be some upside to adding the type, because on the face of it the implementations achieve the same goal. Also it looks like the implementation of <code>compareTo(Object o)</code> may be giving us more information because we could be testing for <code>instanceof</code> and potentially handling errors.</p>