compareTo: how to return a boolean?
<p>I am told that compareTo has to return an int...not Boolean.<br/>
For example:<br/></p>

<p>Returns</p>

<p>0 if a equal b<br/>
-1 if a &lt; b<br/>
+1 if a > b<br/></p>

<p>I am slightly confused by that. Any help would be greatly appreciated.</p>

<pre><code>public int compareTo(Cheese anotherCheese)
   throws ClassCastException
   {
       if (!(anotherCheese instanceof Cheese))
            throw new ClassCastException("A Cheese object expected.");

       if(getCheeseType().compareTo(anotherCheese.getCheeseType()))
            return -1;
       else if (getCheeseType().compareTo(anotherCheese.getCheeseType()))
            return 1;
       else
            return cheesePrice &gt; anotherCheese.getCheesePrice();
   }   
</code></pre>

<p>When I compile, I get the error messages saying:</p>

<p><br>
incompatible types<br/>
<code>if(getCheeseType().compareTo(anotherCheese.getCheeseType()))</code><br/>
incompatible types<br/>
<code>else if (getCheeseType().compareTo(anotherCheese.getCheeseType()))</code><br/>
incompatible types<br/>
<code>return cheesePrice &gt; anotherCheese.getCheesePrice();</code><br/></p>
