title: Class cannot be cast to java.lang.Comparable even if the comparable is implemented
body: <p>I want to sort an arraylist which contains "Counter" objects with Collections.sort() method. I have implemented the comparable interface in the Counter class. Still i get a class cast exception. I have posted the code below. </p>
  
  <pre><code>public class Counter implements Comparable&lt;Counter&gt;, java.io.Serializable {
  
      private String description;
  
      public Counter() {
      }
  
      public Counter(String description) {
  
          this.description = description;
  
      }
  
      public int compareTo(Counter other) {
          return description.compareTo(other.description);
      }
  }
  </code></pre>
  
  <p>The below method is where i call the sort method. </p>
  
  <pre><code>    protected List &lt; Counter &gt; prepareCounters(final Integer authorityID) throws ServiceException {
      if (authorityID == null) {
          return new ArrayList &lt; Counter &gt;();
      }
  
      List &lt; Counter &gt; countersInRegistry = new ArrayList &lt; Counter &gt;(counterRegistry.getAllCounters());
      List &lt; Counter &gt; countersFromService =
              new ArrayList &lt; Counter &gt;(counterService.searchCounters(authorityID, null, null));
      countersFromService.removeAll(countersInRegistry);
      Collections.sort(countersFromService);
      return countersFromService;
  }
  </code></pre>