title: Java warning with implementing Comparable
body: <p>I'm trying to use Collections.sort on a ArrayList of custom objects, but I'm getting a warning and I can't figure out why</p>
  
  <pre><code>Warning: Type safety: Unchecked invocation 
  sort(ArrayList&lt;CharProfile&gt;) of the generic method sort(List&lt;T&gt;) 
  of type Collections
  </code></pre>
  
  <p>With this code:</p>
  
  <pre><code>ArrayList&lt;CharProfile&gt; charOccurrences = new ArrayList&lt;CharProfile&gt;();
  
  ...
  
  Collections.sort(charOccurrences);
  </code></pre>
  
  <p>And here's my method:</p>
  
  <pre><code>public class CharProfile implements Comparable {
  
  ...
  
  @Override
  public int compareTo(Object o) {
  
          if (this.probability == ((CharProfile)o).getProbability()) {
              return 0;
          }
          else if (this.probability &gt; ((CharProfile)o).getProbability()) {
              return 1;
          }
          else {
              return -1;
          }
   }
  }
  </code></pre>