title: Comparator compare method() int cannot be dereferenced
body: <p>I'm doing some assignment work and I've struck a problem.</p>
  <p>I've been given this example code:</p>
  <pre class="lang-java prettyprint-override"><code>public class PersonNameComparator implements Comparator&lt;Person&gt;{
      public int compare(Person p1, Person p2) {
          int retValue = p1.getName().compareTo(p2.getName());
          if (retValue != 0)
              return retValue;
          else if (p1.getAge() &lt; p2.getAge())
              return -1;  
          else if (p1.getAge() &gt; p2.getAge())
              return 1;
          else
              return 0;
      }
  }
  </code></pre>
  <p>However, when I try to do this, this happens:</p>
  <pre class="lang-java prettyprint-override"><code>public class DVDComparator implements Comparator &lt;DVD&gt; {
       
      public int compare(DVD d1,DVD d2)
          {       
           int stars1 = d1.getNoOfStars().compareTo(d2.getNoOfStars());
           //ERROR - int cannot be dereferenced.
  </code></pre>
  <p>Any ideas?</p>