title: Why am I getting this error about the compareTo method?
body: <p>I am trying to understand the <code>compareTo</code> method. I wrote this class <code>AboutcompareTo</code>, but i am stuck in why/how i get this error?- the code is nearly finished.
  anyone can explain in details what i am doing wrong. Thanks</p>
  
  <p>the code:</p>
  
  <pre><code>public class AboutCompareTo {
  
      public static void main(String[] args) {
          Fruit[] fruits = { new Fruit(2), new Fruit(3), new Fruit(1) };
          java.util.Arrays.sort(fruits);
      }
  
  }
  
  class Fruit implements Comparable&lt;Fruit&gt; {
      private double weight;
  
      public Fruit(double weight) {
          this.weight = weight;
      }
  
      @Override
      public int compareTo(Fruit o) {
          Fruit f = (Fruit) o;
          if (Fruit &gt; o.Fruit)  // &lt;-- the error
              return 1;
          else if ((Fruit &lt; o.Fruit))  // &lt;-- the error
              return -1;
          else
              return 0;
  
      }
  
  } 
  </code></pre>