title: List to TreeSet conversion produces: "java.lang.ClassCastException: MyClass cannot be cast to java.lang.Comparable"
body: <pre><code>List&lt;MyClass&gt; myclassList = (List&lt;MyClass&gt;) rs.get();
  
  TreeSet&lt;MyClass&gt; myclassSet = new TreeSet&lt;MyClass&gt;(myclassList);
  </code></pre>
  
  <p>I don't understand why this code generates this:</p>
  
  <pre><code>java.lang.ClassCastException: MyClass cannot be cast to java.lang.Comparable
  </code></pre>
  
  <p>MyClass does not implement Comparable. I just want to use a Set to filter the unique elements of the List since my List contains unncessary duplicates.</p>