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>Warning: Type safety: Unchecked invocation sort(ArrayList) of the generic method sort(List) of type Collections</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) {
        else {
            if (this.probability == ((CharProfile)o).getProbability()) {
                return 0;
            }
            else if (this.probability &gt; ((CharProfile)o).getProbability()) {
                return 1;
            }
            else {
                return -1;
            }
        }
    }
</code></pre>
